PSEventManager.SubscribeEvent Method

Definition

Overloads

SubscribeEvent(Object, String, String, PSObject, PSEventReceivedEventHandler, Boolean, Boolean)

Subscribes to an event on an object.

SubscribeEvent(Object, String, String, PSObject, ScriptBlock, Boolean, Boolean)

Subscribes to an event on an object.

SubscribeEvent(Object, String, String, PSObject, PSEventReceivedEventHandler, Boolean, Boolean, Int32)

Subscribes to an event on an object.

SubscribeEvent(Object, String, String, PSObject, ScriptBlock, Boolean, Boolean, Int32)

Subscribes to an event on an object.

SubscribeEvent(Object, String, String, PSObject, PSEventReceivedEventHandler, Boolean, Boolean)

Subscribes to an event on an object.

public:
 abstract System::Management::Automation::PSEventSubscriber ^ SubscribeEvent(System::Object ^ source, System::String ^ eventName, System::String ^ sourceIdentifier, System::Management::Automation::PSObject ^ data, System::Management::Automation::PSEventReceivedEventHandler ^ handlerDelegate, bool supportEvent, bool forwardEvent);
public abstract System.Management.Automation.PSEventSubscriber SubscribeEvent (object source, string eventName, string sourceIdentifier, System.Management.Automation.PSObject data, System.Management.Automation.PSEventReceivedEventHandler handlerDelegate, bool supportEvent, bool forwardEvent);
abstract member SubscribeEvent : obj * string * string * System.Management.Automation.PSObject * System.Management.Automation.PSEventReceivedEventHandler * bool * bool -> System.Management.Automation.PSEventSubscriber
Public MustOverride Function SubscribeEvent (source As Object, eventName As String, sourceIdentifier As String, data As PSObject, handlerDelegate As PSEventReceivedEventHandler, supportEvent As Boolean, forwardEvent As Boolean) As PSEventSubscriber

Parameters

source
Object

The source object that defines the event

eventName
String

The event to subscribe

sourceIdentifier
String

An optional subscription identifier to help identify this event subscription

data
PSObject

Any additional data you wish to attach to the event

handlerDelegate
PSEventReceivedEventHandler

Any action to be invoked when the event arrives

supportEvent
Boolean

Any action to be invoked when the event arrives

forwardEvent
Boolean

Whether events in this subscriber should be forwarded to the client PowerShell during remote executions

Returns

Applies to

SubscribeEvent(Object, String, String, PSObject, ScriptBlock, Boolean, Boolean)

Subscribes to an event on an object.

public:
 abstract System::Management::Automation::PSEventSubscriber ^ SubscribeEvent(System::Object ^ source, System::String ^ eventName, System::String ^ sourceIdentifier, System::Management::Automation::PSObject ^ data, System::Management::Automation::ScriptBlock ^ action, bool supportEvent, bool forwardEvent);
public abstract System.Management.Automation.PSEventSubscriber SubscribeEvent (object source, string eventName, string sourceIdentifier, System.Management.Automation.PSObject data, System.Management.Automation.ScriptBlock action, bool supportEvent, bool forwardEvent);
abstract member SubscribeEvent : obj * string * string * System.Management.Automation.PSObject * System.Management.Automation.ScriptBlock * bool * bool -> System.Management.Automation.PSEventSubscriber
Public MustOverride Function SubscribeEvent (source As Object, eventName As String, sourceIdentifier As String, data As PSObject, action As ScriptBlock, supportEvent As Boolean, forwardEvent As Boolean) As PSEventSubscriber

Parameters

source
Object

The source object that defines the event

eventName
String

The event to subscribe

sourceIdentifier
String

An optional subscription identifier to help identify this event subscription

data
PSObject

Any additional data you wish to attach to the event

action
ScriptBlock

Any action to be invoked when the event arrives

supportEvent
Boolean

Any action to be invoked when the event arrives

forwardEvent
Boolean

Whether events in this subscriber should be forwarded to the client PowerShell during remote executions

Returns

Applies to

SubscribeEvent(Object, String, String, PSObject, PSEventReceivedEventHandler, Boolean, Boolean, Int32)

Subscribes to an event on an object.

public:
 abstract System::Management::Automation::PSEventSubscriber ^ SubscribeEvent(System::Object ^ source, System::String ^ eventName, System::String ^ sourceIdentifier, System::Management::Automation::PSObject ^ data, System::Management::Automation::PSEventReceivedEventHandler ^ handlerDelegate, bool supportEvent, bool forwardEvent, int maxTriggerCount);
public abstract System.Management.Automation.PSEventSubscriber SubscribeEvent (object source, string eventName, string sourceIdentifier, System.Management.Automation.PSObject data, System.Management.Automation.PSEventReceivedEventHandler handlerDelegate, bool supportEvent, bool forwardEvent, int maxTriggerCount);
abstract member SubscribeEvent : obj * string * string * System.Management.Automation.PSObject * System.Management.Automation.PSEventReceivedEventHandler * bool * bool * int -> System.Management.Automation.PSEventSubscriber
Public MustOverride Function SubscribeEvent (source As Object, eventName As String, sourceIdentifier As String, data As PSObject, handlerDelegate As PSEventReceivedEventHandler, supportEvent As Boolean, forwardEvent As Boolean, maxTriggerCount As Integer) As PSEventSubscriber

Parameters

source
Object

The source object that defines the event

eventName
String

The event to subscribe

sourceIdentifier
String

An optional subscription identifier to help identify this event subscription

data
PSObject

Any additional data you wish to attach to the event

handlerDelegate
PSEventReceivedEventHandler

Any action to be invoked when the event arrives

supportEvent
Boolean

Any action to be invoked when the event arrives

forwardEvent
Boolean

Whether events in this subscriber should be forwarded to the client PowerShell during remote executions

maxTriggerCount
Int32

Indicate how many times the subscriber should be triggered before auto-unregister it If the value is equal or less than zero, there is no limit on the number of times the event can be triggered without being unregistered

Returns

Applies to

SubscribeEvent(Object, String, String, PSObject, ScriptBlock, Boolean, Boolean, Int32)

Subscribes to an event on an object.

public:
 abstract System::Management::Automation::PSEventSubscriber ^ SubscribeEvent(System::Object ^ source, System::String ^ eventName, System::String ^ sourceIdentifier, System::Management::Automation::PSObject ^ data, System::Management::Automation::ScriptBlock ^ action, bool supportEvent, bool forwardEvent, int maxTriggerCount);
public abstract System.Management.Automation.PSEventSubscriber SubscribeEvent (object source, string eventName, string sourceIdentifier, System.Management.Automation.PSObject data, System.Management.Automation.ScriptBlock action, bool supportEvent, bool forwardEvent, int maxTriggerCount);
abstract member SubscribeEvent : obj * string * string * System.Management.Automation.PSObject * System.Management.Automation.ScriptBlock * bool * bool * int -> System.Management.Automation.PSEventSubscriber
Public MustOverride Function SubscribeEvent (source As Object, eventName As String, sourceIdentifier As String, data As PSObject, action As ScriptBlock, supportEvent As Boolean, forwardEvent As Boolean, maxTriggerCount As Integer) As PSEventSubscriber

Parameters

source
Object

The source object that defines the event

eventName
String

The event to subscribe

sourceIdentifier
String

An optional subscription identifier to help identify this event subscription

data
PSObject

Any additional data you wish to attach to the event

action
ScriptBlock

Any action to be invoked when the event arrives

supportEvent
Boolean

Any action to be invoked when the event arrives

forwardEvent
Boolean

Whether events in this subscriber should be forwarded to the client PowerShell during remote executions

maxTriggerCount
Int32

Indicate how many times the subscriber should be triggered before auto-unregister it If the value is equal or less than zero, there is no limit on the number of times the event can be triggered without being unregistered

Returns

Applies to