34,333
edits
Changes
→Writing to Files in Windows PowerShell
== Writing to Files in Windows PowerShell ==
Content is written to files in Windows PowerShell using the ''''Set-Content'' and ''Out-File'' cmdlets. Whilst both commands write data to files, each provides diferrent different results. ''Set-Content'' writes the raw data to the file in the form in which it is received by the cmdlet. ''Out-File'', on the other hand, will format the output for human consumption (in much the way content is formatted by default when displayed in the Windows PowerShell console). As such, ''Out-File'' is unsuitable for writing binary files.
As an example of reading and writing files, the following command make a binary copy of the Windows ''winhelp.exe'' executable binary file: