Unregister-Event - PowerShell


 

Cancels an event subscription. (Unregister-Event)

   

# NAME
Unregister-Event

# SYNOPSIS
Cancels an event subscription.

# SYNTAX
Unregister-Event [-SubscriptionId] <int> [-Force] [-Confirm] [-WhatIf] [<CommonParameters>]

Unregister-Event [-SourceIdentifier] <string> [-Force] [-Confirm] [-WhatIf] [<CommonParameters>]

# 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.

# PARAMETERS
-Force [<SwitchParameter>]
Cancels all event subscriptions, including subscriptions that were hidden by using the SupportEvent parameter of Register-ObjectEvent, Register-WmiEvent, and Register-EngineEvent.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-SourceIdentifier <string>
Cancels event subscriptions that have the specified source identifier.

A SourceIdentifier or SubscriptionId parameter must be included in every command.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-SubscriptionId <int>
Cancels event subscriptions that have the specified subscription identifier.

A SourceIdentifier or SubscriptionId parameter must be included in every command.

Required? true
Position? 1
Default value
Accept pipeline input? true (ByPropertyName)
Accept wildcard characters? false

-Confirm [<SwitchParameter>]
Prompts you for confirmation before executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-WhatIf [<SwitchParameter>]
Describes what would happen if you executed the command without actually executing the command.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer and OutVariable. For more information, type,
"get-help about_commonparameters".

# INPUTS
System.Management.Automation.PSEventSubscriber
You can pipe the output from Get-EventSubscriber to Unregister-Event.

# OUTPUTS
None
This cmdlet does not return any output.

# NOTES

Events, event subscriptions, and the event queue exist only in the current session. If you close the current session, the event queue is discarded and the event subscription is canceled.

Unregister-Event cannot delete events created by using the New-Event cmdlet unless you have subscribed to the event by using the Register-EngineEvent cmdlet. To delete a custom event from the session, you must remove it programmatically or close the session.

# EXAMPLE 1

C:\PS>unregister-event -sourceIdentifier ProcessStarted

# Description
-----------
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

C:\PS>unregister-event -subscriptionId 2

# Description
-----------
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

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

# Description
-----------
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.

RELATED LINKS
Online version: http://go.microsoft.com/fwlink/?LinkID=135269
Register-ObjectEvent
Register-EngineEvent
Register-WmiEvent
Unregister-Event
Get-Event
New-Event
Remove-Event
Wait-Event
Get-EventSubscriber

C:\Windows>powershell get-help New-Event -full

ColorConsole [Version 1.7.1000] PowerShell 2.0-Export
Microsoft Windows [Version 6.1.7600]
Copyright (c) 2014 Microsoft Corporation.

OS: Windows 10, 8.1, 8, 7, Vista / Windows Server 2016, 2012, 2008
»»»» ColorConsole








Windows-10





Windows-10

... facebook.de
... Windows-10 FAQ
... Windows-10 Info


Become a Sponsor
... Your button here?





PowerShell: Cancels an event subscription.

HTTP: ... PS_Windows/en/Unregister-Event.htm
0.171
10573

Eigenes Benutzerkonto-Bild in Windows 8.1 ändern (löschen, login)?

 /

Create desktop program shortcuts in Windows 8/8.1 and Win 10! 

 /

Can I turn off or enable hibernate in windows 7?

 /

Auto create system restore points in Windows 8.1 / 10, how to enable/disable and/or adjust?

 /

I'm looking to install your program on multiple computer?

 /

Einrichten von kontrolliertem Zugriff auf Ordner in Windows-10!

 /

What is the XPS Viewer in Windows 10, can i uninstall it (printer)?

 /

File search with filter and (include or exclude) the files!

 /

Scann und Qualität in Win Scann 2 PDF!

 /

Over 1000 snowflakes on the Windows desktop with low CPU load!

 /

8 Mouse Balls for on the Desktop for Windows (10, 8.1, 7, ...)!

 /

Wie aktiviere ich die Favoriten im Windows 7 Startmenü?

 /