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.csv
if 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

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607