How to export data to CSV in PowerShell?
foreach ($computer in $computerlist) { if((Test-Connection -Cn $computer -BufferSize 16 -Count 1 -ea 0 -quiet)) { foreach ($file in $REMOVE) { Remove-Item "\\$computer\$DESTINATION\$file" -Recurse Copy-Item E:\Code\powershell\shortcuts\* "\\$computer\$DESTINATION\" } } else { Write-Host "\\$computer\$DESTINATION\" } } I want to export Write-Host "\$computer\$DESTINATION\" to the CSV files so I know which computers were offline when the script ran. I am running this from a Windows 7 machine This solution creates a psobject and adds each object to an array, it then creates the csv by piping the