After executing your script you will like to save some of the outputs to a file. There is a simple way to do this in PowerShell.
“Hello” | out-file c:file.txt
Append test to an existing file
“Hello 2” | out-file c:file.txt -append
To create a comma separated value use the export-csv command. This example will create a csv file with all the process from the computer and sort them by CPU usage.
Get-Process | select name, cpu | sort cpu -Descending | Export-Csv c:file.csv -notypeinformation