Powershell get-content text file and loot to run msinfo32.exe -
$computers = get-content -path c:\output\output.txt $output = '\\pcname\c$\output\' $output1 = '.txt' ($output2 =$output+$computers+$output1) msinfo32.exe /report $output2 /computer $computer
what getting msinfo32.exe /report $output2 /computer $computer reading first pcname , name , writing file name each pcname space between each of them. sorry seem simple question started using ps.
thanks
you've got 2 issues here.
- to concatenate strings path, need use
join-path
- you're getting first computer name because aren't looping through list of computers.
quick & dirty revision (assumes each computer name on own line in output.txt
)
$computers = get-content -path c:\output\output.txt; $output = '\\pcname\c$\output\'; $output1 = '.txt'; $computers | foreach-object { $output2 = (join-path -path $output -childpath $_) + ".txt"; msinfo32.exe /report $output2 /computer $_; }
Comments
Post a Comment