Hey all,
I'm trying to read in a text file from multiple computers using a ForEach statement and getting an error that the file does not exist. I'm 100% positive the file is there but I must have some syntax/setup problems in the script thus producing the error.
clear-host
function info{
ForEach ($pc in $pclist){
if(Test-Connection -cn $pc.name -Count 1 -quiet){
$readme = Get-Content "\\$_\c$\software\readme.txt"
$pc.Name+","+"ON"+","+"$readme"
}
Else{
$pc.Name+","+"OFF"+","+"N/A"
}
}
}
$pclist=Import-Csv -Path \\server\E\Scripts\PC_List.csv
info | Out-File c:\users\$env:username\Desktop\pc_readme.txt