Fix non-functioning events
This commit is contained in:
parent
30f98c4cb1
commit
5e6eebf8ad
1 changed files with 11 additions and 1 deletions
|
@ -141,7 +141,17 @@ function Start-EventDrivenTask() {
|
|||
)
|
||||
$identifier = "EventLog$EventID";
|
||||
Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username";
|
||||
Register-WmiEvent -Query "SELECT * FROM __InstanceCreationEvent WHERE TargetInstance ISA 'Win32_NTLogEvent' AND EventIdentifier=$EventID" -SourceIdentifier "$identifier";
|
||||
|
||||
$applicationLog = Get-EventLog -List | Where-Object { $_.Log -eq "Application" };
|
||||
|
||||
Register-ObjectEvent -InputObject $applicationLog -EventName EntryWritten -Action {
|
||||
$entry = $event.SourceEventArgs.Entry;
|
||||
|
||||
if ($entry.EventID -eq $EventID) {
|
||||
New-Event -SourceIdentifier $identifier;
|
||||
}
|
||||
};
|
||||
|
||||
Wait-Event -SourceIdentifier $identifier;
|
||||
} -args $EventID
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue