diff --git a/scripts/Windows/OS/User/Add.ps1 b/scripts/Windows/OS/User/Add.ps1 index 34a4b8b1..db271138 100644 --- a/scripts/Windows/OS/User/Add.ps1 +++ b/scripts/Windows/OS/User/Add.ps1 @@ -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 }