Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 2.0 » Register-EngineEvent

Register-EngineEvent - 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.

Register-EngineEvent


Short description
Subscribes to events that are generated by the Windows PowerShell engine and by the New-Event cmdlet.

Syntax
Register-EngineEvent [-SourceIdentifier] <string> [[-Action] <scriptblock>] [-Forward] [-MessageData <psobject>] [-
SupportEvent] [<CommonParameters>]

Description
The Register-EngineEvent cmdlet subscribes to events that are generated by the Windows PowerShell engine and the Ne
w-Event cmdlet. Use the SourceIdentifier parameter to specify the event.

You can use this cmdlet to subscribe to the "Exiting" engine event and events generated by the New-Event cmdlet. Th
ese events are automatically added to your event queue in your session without subscribing. However, subscribing le
ts you forward the events, specify an action to respond to the events, and cancel the subscription. 

When the subscribed event is raised, it is added to the event queue in your session. To get events in the event que
ue, use the Get-Event cmdlet. 

When you subscribe to a event, an event subcriber is added to your session. To get the event subscribers in the ses
sion, use the Get-EventSubscriber cmdlet. To cancel the subscription, use the Unregister-Event cmdlet, which delete
s the event subscriber from the session.