![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| xp 32 | powershell script to execute simultaneously instead of sequentially i would like to execute a script to execute the same command to a list of servers, listed in a text file (hopefully later from an excel file), simultaneously by opening separate foreground powershell windows to run the command per machine name. i have figured out how to run it sequentially by pulling the array of names from the txt file and using the names as the variable but with many machines - this takes much too long. i dont want to do this as a background job as i like seeing the action as it happens on all the machines. i can and do currently have a script that i can enter the names individually as well but this is error prone as i can skip a name by accident. i.e. as an example - i would like to take a text file with 50 pc names - and have a script open 50 seperate powershell windows simlultaneously per pc name and ping them all and import the results back to the local machine.... this should be rather simple but i cant figure it out...! |
My System Specs![]() |
| | #2 (permalink) |
| | Re: powershell script to execute simultaneously instead of sequentially Well, opening 50 console windows is not going to be trivial, in terms of time/resources, but ... you would run something like: # get your data here, somehow $servers = gc servers.txt $procs = $( foreach($server in $servers) { $si = New-Object -TypeName System.Diagnostics.ProcessStartInfo $si.FileName = "powershell.exe" $si.Arguments = "-command ping.exe $server" [diagnostics.process]::Start($si) } ) But there's no easy way to get the output from a console window if you let it start up in GUI mode like that, so I definitely don't recommend going that route. -- Joel jlo wrote: Quote: > i would like to execute a script to execute the same command to a list > of servers, listed in a text file (hopefully later from an excel file), > simultaneously by opening separate foreground powershell windows to run > the command per machine name. > > i have figured out how to run it sequentially by pulling the array of > names from the txt file and using the names as the variable but with > many machines - this takes much too long. i dont want to do this as a > background job as i like seeing the action as it happens on all the > machines. > i can and do currently have a script that i can enter the names > individually as well but this is error prone as i can skip a name by > accident. > > i.e. as an example - i would like to take a text file with 50 pc names > - and have a script open 50 seperate powershell windows simlultaneously > per pc name and ping them all and import the results back to the local > machine.... > this should be rather simple but i cant figure it out...! > > |
My System Specs![]() |
| | #3 (permalink) |
| xp 32 | i was able to apply this for the ping but this didnt work when i tried to use an existing script in place of the ping command. its a great start though... any thoughts on how to adapt it to a script as the command and the location variable pulled from the txt file? |
My System Specs![]() |
| | #4 (permalink) |
| XP | Re: powershell script to execute simultaneously instead of sequentially An another way : Split-Job (use runspace Posh V1) |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Permissions to execute the script | VB Script | |||
| execute Exchange script from DOS - how to get result? | PowerShell | |||
| Execute a powershell script from a webpage | PowerShell | |||
| Powershell Execute process | PowerShell | |||
| execute powershell script from commmand line | PowerShell | |||