CmdID

CmdID / PowerShell / Cmdlets / Get

Get-EventSubscriber

Gets the event subscribers in the current session. PowerShell reference

From the PowerShell reference 3 parameters

Opens CmdID with your command, read as PowerShell. It is read in your browser and sent nowhere.

What it does

from the PowerShell reference, CC BY 4.0

Gets the event subscribers in the current session. The Get-EventSubscriber cmdlet gets the event subscribers in the current session. When you subscribe to an event by using a Register event cmdlet, an event subscriber is added to your Windows PowerShell session, and the events to which you subscribed are added to your event queue whenever they are raised. To cancel an event subscription, delete the event subscriber by using the Unregister-Event cmdlet.

Get-EventSubscriber [[-SourceIdentifier] <String>] [-Force] [<CommonParameters>]
Get-EventSubscriber [-SubscriptionId] <Int32> [-Force] [<CommonParameters>]

Get the event subscriber for a timer event

$Timer = New-Object Timers.Timer $Timer | Get-Member -Type EventIdentify

Use the dynamic module in PSEventJob in the Action property of the event subscriber

$Timer = New-Object Timers.Timer $Timer.Interval = 500 $params = @{ InputObject = $Timer EventName = 'Elapsed' SourceIdentifier = 'Timer.Random' Action = { $Random = Get-Random -Min 0 -Max 100 } } Register-ObjectEvent @paramsIdentify

Get hidden event subscribers

Register-EngineEvent -SourceIdentifier PowerShell.Exiting -SupportEvent -Action { Get-History | Export-Clixml D:\temp\history.clixml } Get-EventSubscriber # No output - must use -Force Get-EventSubscriber -ForceIdentify

Its page in the reference: Get-EventSubscriber.

Parameters

3 in the PowerShell reference
-ForceIndicates that this cmdlet gets all event subscribers, including subscribers for events that are hidden by using the SupportEvent parameter of Register-ObjectEvent, Register-WmiEvent, and Register-EngineEvent.
-SourceIdentifierSpecifies the SourceIdentifier property value that gets only the event subscribers. By default, Get-EventSubscriber gets all event subscribers in the session. Wildcards are not permitted. This parameter is case-sensitive.
-SubscriptionIdSpecifies the subscription identifier that this cmdlet gets. By default, Get-EventSubscriber gets all event subscribers in the session.