Hello all,
before digging into the script, maybe someone sees something I missed...
$range = 1..100
ForEach ($_ in $range){
if ($_ % 7 -ne 0 ) { continue; }
$timer = New-Object System.Timers.Timer
Register-ObjectEvent -InputObject $timer -EventName Elapsed -Action { continue; }
$timer.Interval = 1000
$timer.Autoreset = $false
$timer.Enabled = $true
Start-Sleep -s 10
Write-Host "$($_) is a multiple of 7"
}What I am trying to do is skip one step in a foreach loop (basically when a WMI Query does not finish, though that's not in the example code). So in general, using continue works fine (if mod 7 != 0 will skip the step of the foreach loop), using continue with the timer wont work. if I replace the continue; in the action with eg Write-Host 'Event Fired';, I can see that the Timer as such does work and does fire the event.
Curious, should it work or have I missed the obvious?
Thanks
Florian