No problem, it’s anyway useful, thank you!
A simple workaround is to put the same code of the Action
block right after Wait-Event Timer.Elapsed
:
Wait-Event Timer.Elapsed
Write-Host "Action triggered"
It works this way (even if automatic variables like $Event
, $Sender
, etc. will not be available).
Ok, so IIUC the timer expiration (that is: this specific event) can be detected by Wait-Event
only once in that single PowerShell terminal. Once it has been consumed, Wait-Event
is done.
Both the things. I am playing around and trying to better understand the Register-ObjectEvent
and Wait-Event
usages, because of the issues I’m having in this thread.
Thank you so much!