Create a new event.
Syntax New-Event [[-SourceIdentifier] string] [[-Sender] psobject] [[-EventArguments] PSObject[]] [[-MessageData] psobject] [CommonParameters] Key: -EventArguments PSObject[] An object that contains options for the event. -MessageData psobject Additional data associated with the event. The value of this parameter appears in the MessageData property of the event object. -Sender psobject The object that raises the event. The default is the Windows PowerShell engine. -SourceIdentifier string A a name for the new event. This parameter is required, and it must be unique in the session. The value of this parameter appears in the events SourceIdentifier property. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.
Use custom events to notify users about state changes in a program and any change that the program can
detect, including hardware or system conditions, application status, disk status, network status, or the completion
of a background job.
Register-EngineEvent can be used to subscribe to the custom event and thus specify an action in response
to the event,
When you subscribe to a custom event, the event subscriber is added to your session. If you cancel the event subscription by using the Unregister-Event cmdlet, the event subscriber and custom event are deleted from the session. If
you do not subscribe to the custom event, to delete the event, you must change the program conditions or close the
PowerShell session.
Examples
Create a new event in the PowerShell event queue. Use a Windows.Timer object to send the event:
PS C:\> new-event -sourceidentifier Timer -sender windows.timer -messagedata "Test"
“What old people say you cannot do, you try and find that you can. Old deeds for old people, and new deeds for new” ~ Henry David Thoreau
Related PowerShell Cmdlets:
Get-Event - Get events in the event queue.
Remove-Event - Delete events from the event queue.