I need to have a permanent background monitor running to run a command if a certain event occurs.
I am confused by all the parameters which may be necessary to accomplish so could somebody please supply a simple solution?
$action10 = { $GLOBAL:MyNewEvent = $Event Write-Host "Event arrived!" }$query10 = "SELECT * FROM __InstanceCreationEvent WHERE TargetInstance ISA ` 'Win32_NTLogEvent' AND TargetInstance.EventCode = '10000' AND ` TargetInstance.SourceName = 'NetworkProfile'"Register-WmiEvent -Query $query10 -SourceIdentifier 'OnlineStatus' -Action $action10 ` | Out-Null
The above is the code which should work, but fails to give any response. Does anyone have any idea why?