direct powershell to file code example
Example 1: powershell output to file
ls | Out-File -FilePath c:\PATH\TO\FOLDER\OUTPUT.txt
Example 2: powershell output text file
Out-File fileName
ls | Out-File -FilePath c:\PATH\TO\FOLDER\OUTPUT.txt
Out-File fileName