PowerShell Logo Small

Unregister-Event



This is the built-in help made by Microsoft for the command 'Unregister-Event', in PowerShell version 5 - as retrieved from Windows version 'Microsoft Windows Server 2012 R2 Standard' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Cancels an event subscription.

SYNTAX


Unregister-Event [-SourceIdentifier] <String> [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String>]] [-Confirm] [-WhatIf] [<CommonParameters>]
Unregister-Event [-SubscriptionId] <Int32> [-Force] [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable
[<System.String>]] [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Unregister-Event cmdlet cancels an event subscription that was created by using the Register-EngineEvent, Register-ObjectEvent, or Register-WmiEvent cmdlet.


When an event subscription is canceled, the event subscriber is deleted from the session and the subscribed events are no longer added to the event queue. When you cancel a
subscription to an event created by using the New-Event cmdlet, the new event is also deleted from the session.


Unregister-Event does not delete events from the event queue. To delete events, use the Remove-Event cmdlet.



<

RELATED LINKS

Online Version: http://go.microsoft.com/fwlink/p/?linkid=294022
Get-Event
Get-EventSubscriber
New-Event
Register-EngineEvent
Register-ObjectEvent
Register-WmiEvent
Remove-Event
Unregister-Event
Wait-Event

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

PS C:\>unregister-event -sourceIdentifier ProcessStarted



This command cancels the event subscription that has a source identifier of "ProcessStarted".

To find the source identifier of an event, use the Get-Event cmdlet. To find the source identifier of an event subscription, use the Get-EventSubscriber cmdlet.










-------------------------- EXAMPLE 2 --------------------------

PS C:\>unregister-event -subscriptionId 2



This command cancels the event subscription that has a subscription identifier of 2.

To find the subscription identifier of an event subscription, use the Get-EventSubscriber cmdlet.










-------------------------- EXAMPLE 3 --------------------------

PS C:\>get-eventsubscriber -force | unregister-event -force



This command cancels all event subscriptions in the session.

The command uses the Get-EventSubscriber cmdlet to get all event subscriber objects in the session, including the subscribers that are hidden by using the SupportEvent
parameter of the event registration cmdlets.

It uses a pipeline operator (|) to send the subscriber objects to Unregister-Event, which deletes them from the session. To complete the task, the Force parameter is also
required on Unregister-Event.