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.

  1. to concatenate strings path, need use join-path
  2. 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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -