The Out-File cmdlet enables you to send pipelined output directly to a text file rather than displaying that output on screen. For example, this command retrieves process information using Get-Process, then uses Out-File to write the data to the file C:\Scripts\Test.txt:
Get-Process | Out-File c:\scripts\test.txt
By default Out-File saves the data exactly the way that data appears in your Windows PowerShell console. That means that some of the data could end up truncated.
That’s a problem, but it’s an easy problem to solve: just include the -width parameter and specify a different line width (in characters) for the text file. For example, this revised command sets the line width to 120 characters:
Get-Process | Out-File c:\scripts\test.txt -width 120