Some Powershell commands or cmdlets Part 9 – Using Outfile to save a file in ASCII and other non Unicode format


Using Outfile to write information as a different file format

In Posh the ouput is written in Unicode.
However there are some files and applications that require output in ASCII format file.
To make sure you save a file in ASCII format (or other format than Unicode) use the cmdlet “out-file”
out-file requires -FilePath instead of -Path as an argument. Here is an example:
Get-Event -LogName application -Newest 3 | Out-File -FilePath C:\posh\event1.tst -encoding ascii
to verify if the command finished successfuly, you type

$?

if worked fine then a “TRUE” is returned

outfile path encoding ascii
switches:

-noclobber = do not ovewrite the file

-width = specifies the width of the file e.g. 1000 meaning 1000 characters long

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: