Fix run condition

This commit is contained in:
Manuel Thalmann 2024-03-22 16:15:37 +01:00
parent 5290d3283a
commit de8999c361

View file

@ -140,8 +140,6 @@ function Start-EventDrivenTask() {
[int]$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" };
Register-ObjectEvent -InputObject $applicationLog -EventName EntryWritten -Action {
@ -152,6 +150,12 @@ function Start-EventDrivenTask() {
}
};
Wait-Event -SourceIdentifier $identifier;
$job = Start-Job {
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
}