Launch scripts when certain events happen in Windows.
System Events in the Admin Console
System events subscribe to WMI events within Windows and run scripts. You can then take action by running scripts.
To define a system event, you can use the
New-PSUSystemEventcmdlet within the
systemEvents.ps1file. The following example triggers the
systemEvent.ps1script when a
pwsh.exeprocess is started.
New-PSUSystemEvent -Script "systemEvent.ps1" -Environment "Default" -Credential "Default" -Type "Create" -Condition "TargetInstance isa `"Win32_Process`" and TargetInstance.Name = `"pwsh.exe`"" -Name "PowerShell Started"
When a script is executed, you will receive a
$TargetInstanceparameter. This contains the WMI object that caused the event to trigger.
New-BurntToastNotification -Text "PowerShell Started! $TargetInstance"