Monitor Application event log for specific event.

rated by 0 users
This post has 1 Reply | 0 Followers

Top 25 Contributor
Posts 44
Top Contributor
Archdeacon Posted: 09-28-2011 6:43 AM

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?

Top 25 Contributor
Posts 44
Top Contributor

$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?

Page 1 of 1 (2 items) | RSS
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.