PowerTip: Create an ASCII File from Inside PowerShell

Doctor Scripto

Summary: Learn how to create an ASCII file from inside Windows PowerShell.

Hey, Scripting Guy! Question I want to create an ASCII text file to hold the results of the Get-Process cmdlet. How can this be done?

               Hey, Scripting Guy! Answer

a. Pipe the results to the Out-File cmdlet and use the -encoding parameter to specify ASCII:

GPS | Out-File -FilePath c:\fso\myproc.txt -Encoding ascii

b. Use the InputObject parameter of the Out-File cmdlet and use the –encoding parameter to specify ASCII:

Out-File -InputObject (gps) -FilePath c:\fso\myproc.txt -Encoding ascii

c. Use redirection like this:

Get-Process >>c:\fso\myprocess.txt

0 comments

Discussion is closed.

Feedback usabilla icon