What is the syntax to subscribe to an object's static event in PowerShell?
问题 Register-ObjectEvent looks for a object instance in the required parameter InputObject . What is the syntax for an object's static ( Shared ) event? UPDATE : Correct syntax for TimeChanged: $systemEvents = [Microsoft.Win32.SystemEvents] $timeChanged = Register-ObjectEvent -InputObject $systemEvents -EventName 'TimeChanged' -Action { Write-Host "Time changed" } Unfortunately, the SystemEvents will not be signaled in PowerShell ISE . Here's a sample using an object's staic event that works