![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | redirecting standar output when using [System.Diagnostics.Process]::Start Hello all. I want to execute a command against a bunch of IP nodes (servers, routers) in PARALLEL (not one after another). I demonstrate my case using PING, but it could be another tool. The following code works ok: $nodes="server1", "server2", "router1" #... a lot of nodes $nodes | foreach {[System.Diagnostics.Process]::Start("ping.exe","$_") } Now, i need to log all the responses to a unique file for every node, so I try: $nodes | foreach {[System.Diagnostics.Process]::Start("ping.exe","$_ > $_.log 2>&1") } But it's not working. The problem, i think, is the redirection of the standard output and standard error. Thanks for your help. Regards, Freddy Chavez. |
My System Specs![]() |
| | #2 (permalink) |
| | RE: redirecting standar output when using [System.Diagnostics.Process] Does this help $nodes | foreach{ping "$_" | out-file "$_.log" } -- Richard Siddaway Please note that all scripts are supplied "as is" and with no warranty Blog: http://richardsiddaway.spaces.live.com/ PowerShell User Group: http://www.get-psuguk.org.uk "freddy chavez" wrote: > Hello all. I want to execute a command against a bunch of IP nodes (servers, > routers) in PARALLEL (not one after another). I demonstrate my case using > PING, but it could be another tool. > > The following code works ok: > > $nodes="server1", "server2", "router1" #... a lot of nodes > $nodes | foreach {[System.Diagnostics.Process]::Start("ping.exe","$_") } > > Now, i need to log all the responses to a unique file for every node, so I > try: > > $nodes | foreach {[System.Diagnostics.Process]::Start("ping.exe","$_ > > $_.log 2>&1") } > > But it's not working. The problem, i think, is the redirection of the > standard output and standard error. > Thanks for your help. > > Regards, > Freddy Chavez. > > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: redirecting standar output when using [System.Diagnostics.Process]::Start "freddy chavez" <freddychavez22@hotmail.com> wrote in message news:#WG2kxVzHHA.748@TK2MSFTNGP04.phx.gbl... > Hello all. I want to execute a command against a bunch of IP nodes > (servers, routers) in PARALLEL (not one after another). I demonstrate my > case using PING, but it could be another tool. > > The following code works ok: > > $nodes="server1", "server2", "router1" #... a lot of nodes > $nodes | foreach {[System.Diagnostics.Process]::Start("ping.exe","$_") } > > Now, i need to log all the responses to a unique file for every node, so I > try: > > $nodes | foreach {[System.Diagnostics.Process]::Start("ping.exe","$_ > > $_.log 2>&1") } > > But it's not working. The problem, i think, is the redirection of the > standard output and standard error. > Thanks for your help. Redirection via ">" is a feature of a shell (CMD, PowerShell) and not ping.exe. Try this: $nodes | foreach {[System.Diagnostics.Process]::Start("cmd.exe","/c ping.exe $_ > ${_}.log 2>&1") } -- Keith |
My System Specs![]() |
| | #4 (permalink) |
| | Re: redirecting standar output when using [System.Diagnostics.Process]::Start > $nodes | foreach {[System.Diagnostics.Process]::Start("cmd.exe","/c > ping.exe $_ > ${_}.log 2>&1") } > > Keith this was exactly what i've been looking for... thanks a lot Keith !!! |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| [diagnostics.process]::start("exe") | PowerShell | |||
| Question about [System.Diagnostics.Process]::Start() | PowerShell | |||
| Wrap command shell in System.Diagnostics.Process | PowerShell | |||
| Using ProcessStartInfo with [System.Diagnostics.Process]::Start | PowerShell | |||
| Stupid [Diagnostics.Process]::Start("..") tricks | PowerShell | |||