Fix run condition
This commit is contained in:
parent
5290d3283a
commit
de8999c361
1 changed files with 7 additions and 3 deletions
|
@ -140,8 +140,6 @@ function Start-EventDrivenTask() {
|
||||||
[int]$EventID
|
[int]$EventID
|
||||||
)
|
)
|
||||||
$identifier = "EventLog$EventID";
|
$identifier = "EventLog$EventID";
|
||||||
Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username";
|
|
||||||
|
|
||||||
$applicationLog = Get-EventLog -List | Where-Object { $_.Log -eq "Application" };
|
$applicationLog = Get-EventLog -List | Where-Object { $_.Log -eq "Application" };
|
||||||
|
|
||||||
Register-ObjectEvent -InputObject $applicationLog -EventName EntryWritten -Action {
|
Register-ObjectEvent -InputObject $applicationLog -EventName EntryWritten -Action {
|
||||||
|
@ -152,6 +150,12 @@ function Start-EventDrivenTask() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$job = Start-Job {
|
||||||
Wait-Event -SourceIdentifier $identifier;
|
Wait-Event -SourceIdentifier $identifier;
|
||||||
|
Wait-Event -SourceIdentifier $identifier;
|
||||||
|
};
|
||||||
|
|
||||||
|
Write-EventLog -LogName Application -Source "Application" -EventId $EventID -Message "This event was created by $env:Username";
|
||||||
|
Wait-Job $job;
|
||||||
} -args $EventID
|
} -args $EventID
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue