September 6th, 2013

PowerTip: Control Text-File Encoding with PowerShell

Doctor Scripto
Scripter

Summary: Learn how to control text-file encoding with Windows PowerShell.

Hey, Scripting Guy! Question How can I ensure that a file is encoded with Unicode when I write to it?

Hey, Scripting Guy! Answer Use the Out-File cmdlet, and specify the appropriate value for the –Encoding parameter:

Get-Process | Out-File -FilePath c:\fso\myfile.txt -Encoding unicode

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.