Contact Info

Crumbtrail » Administration » Powershell » Powershell 2.0 » Register-WmiEvent

Register-WmiEvent - Powershell 2.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Short description
Subscribes to a Windows Management Instrumentation (WMI) event.

Register-WmiEvent [-Class] <string> [[-SourceIdentifier] <string>] [[-Action] <scriptblock>] [-ComputerName <string
>] [-Credential <PSCredential>] [-Forward] [-MessageData <psobject>] [-Namespace <string>] [-SupportEvent] [-Timeou
t <Int64>] [<CommonParameters>]

Register-WmiEvent [-Query] <string> [[-SourceIdentifier] <string>] [[-Action] <scriptblock>] [-ComputerName <string
>] [-Credential <PSCredential>] [-Forward] [-MessageData <psobject>] [-Namespace <string>] [-SupportEvent] [-Timeou
t <Int64>] [<CommonParameters>]

The Register-WmiEvent cmdlet subscribes to WMI events on the local computer or on a remote computer. 

When the subscribed WMI event is raised, it is added to the event queue in your local session even if the event occ
urs on a remote computer. To get events in the event queue, use the Get-Event cmdlet. 

You can use the parameters of Register-WmiEvent to subscribe to events on remote computers and to specify the prope
rty values of the events that can help you to identify the event in the queue. You can also use the Action paramete
r to specify actions to take when a subscribed event is raised.

When you subscribe to an event, an event subscriber is added to your session. To get the event subscribers in the s
ession, use the Get-EventSubscriber cmdlet. To cancel the subscription, use the Unregister-Event cmdlet, which dele
tes the event subscriber from the session.