Wait for wmi event using powershell
This commit is contained in:
parent
5f02a650ad
commit
30f98c4cb1
1 changed files with 9 additions and 4 deletions
|
@ -135,8 +135,13 @@ function Start-EventDrivenTask() {
|
|||
[int]$EventID
|
||||
);
|
||||
|
||||
$identifier = "EventLog$_";
|
||||
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";
|
||||
Wait-Event -SourceIdentifier $identifier;
|
||||
powershell -c {
|
||||
param (
|
||||
[int]$EventID
|
||||
)
|
||||
$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";
|
||||
Wait-Event -SourceIdentifier $identifier;
|
||||
} -args $EventID
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue