Powershell Timespan and While Loop

  • Follow


Can you use the timespan feature to limit the amount of time that a given task will attempt to execute? I'm attempting to do a system audit, but a lot of the servers are behind firewalls and do not respond, thus I must wait for them to time out. What I'd like to do is say continue to try to contact the server until 10 seconds has passed, and then skip to the next server in the list.

Could I use something like this in my system audit?

$timespan = new-timespan -seconds 10
while ($timespan -ne 10)
{
Code
}

0
Reply SeanT 7/1/2010 2:11:04 PM

Are you using PowerShell v2?  You could start background jobs, then stop 
them if they are taking too long.

Marco

"SeanT" <user@msgroups.net/> wrote in message 
news:O6kS#cSGLHA.4824@TK2MSFTNGP05.phx.gbl...
> Can you use the timespan feature to limit the amount of time that a given 
> task will attempt to execute? I'm attempting to do a system audit, but a 
> lot of the servers are behind firewalls and do not respond, thus I must 
> wait for them to time out. What I'd like to do is say continue to try to 
> contact the server until 10 seconds has passed, and then skip to the next 
> server in the list. 

0
Reply Marco 7/2/2010 1:53:10 AM


1 Replies
932 Views

(page loaded in 0.043 seconds)

Similiar Articles:













8/1/2012 12:23:40 PM


Reply: