Get-Content on list of PC's, UNC Path
good morning,
i new powershell , i'm trying build script automate data gathering.
code:
--
$dir = 'c:\code'
ipcsv $dir\inv.csv | foreach-object { gc "\\pc01\c$\program files\common files\app\license\app.lic" | select-string '#upg' | select-object computer, line | export-csv -notypeinformation -path $dir\output.csv }
import-csv $dir\output.csv
--
i'm able export work great individual pc. however, i'm unable $_.computer portion work in unc path take csv file lists pc's , get-content i'm doing on path. can me out that?
second thing, export grabs line i'm asking '#upg'. i put computer name in output.csv file know line grabbed from.
any ideas on appreciated well.
ps: i'm using powershell v2
thanks much!
hi
try this:
$dir = 'c:\code' ipcsv $dir\inv.csv | foreach-object { gc ("\\"+$_.computer+"\c$\program files\common files\app\license\app.lic") | select-string '#upg' | select-object computer, line | export-csv -notypeinformation -path $dir\output.csv } import-csv $dir\output.csvif doesn't work try this:
$dir = 'c:\code' ipcsv $dir\inv.csv | foreach-object { gc $("\\"+$_.computer+"\c$\program files\common files\app\license\app.lic") | select-string '#upg' | select-object computer, line | export-csv -notypeinformation -path $dir\output.csv } import-csv $dir\output.csv
regards
dan
Windows Server > Windows PowerShell
Comments
Post a Comment