You could play with new-timespan (and properties ... ,seconds, milliseconds, ..
Asked By Jean
30-Jul-07 06:02 PM
You could play with new-timespan (and properties ... ,seconds,
milliseconds, ...)
This one stops after 5 seconds :
$exitafter=5000 #milliseconds
$start=(get-date)
$startms=(new-timespan $start).TotalMilliSeconds
do{
if(
(new-timespan $start).TotalMilliSeconds-$startm `
-ge `
$exitafter-$interval
)
{break} #or {exit}
###CODE###
}while($true)
Regards,
--
Jean - JMST
Belgium
For some reason, this still didn't work.
Asked By Fran
31-Jul-07 04:38 PM
For some reason, this still didn't work. I replaced ###CODE### with "gwmi
win32_logicaldisk -computer test_cluster". It still hangs forever. This
host is the "non-active" cluster.
Thanks,
I'd extracted the code from a bigger project, so what is needed is to break
Asked By Jean
31-Jul-07 05:33 PM
I'd extracted the code from a bigger project, so what is needed is to
break (or exit) at the end of the code otherwize you go in an infinite
loop.
Here is an "example" :
#---8<---
$exitafter=10000
$dir=get-wmiobject win32_Directory
$start=get-date
do{
$dir|%{
$_.Name
if(
(new-timespan $start).TotalMilliSeconds `
-ge `
$exitafter
)
{'***10 SECONDS ELAPSED***';break}
}
'***SCRIPT END***'
break
}while($true)
#---8<---
But i'm not sure this could help you as if I understand well you need
an asynchronous stuff (or an event) and that, just now, I don't know
how to do (and even if it's possible or exists).
Regards,
--
Jean - JMST
Belgium