Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Get-Content on remote machines help

$
0
0

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

 

Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>