I've written a script but cannot get it to export to CSV or output in any way.
PowerShell does not like foreach loops and exporting.
For each "folderpath/filename" in the .txt file it checks to see if the file is still there and outputs true or false + folderpath/file name.
Script works fine, just cannot get the thing to export to CSV.
Any ideas what I'm doing wrong?
foreach ($WantFile in Get-Content "C:\scripts\folderpaths.txt") {
$FileExists = Test-Path $WantFile
if ($FileExists -eq $True) {
Write-Output $wantfile "True"
} else {
Write-Output $wantfile "False"
}
} | Export-Csv C:\scripts\output.csv -noType
output.csv. If you don't know the destination, you can't very well plot a route.Write-Outputinstructions I'd suspect that he wants a CSV with 2 columns: one for the filename and one for the boolean value.