PSEventManager.SubscribeEvent Method

Definition

Overloads

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

Subscribes to an event on an object.

C++
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);

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

PowerShell SDK 7.4.0 et autres versions
Produit Versions
PowerShell SDK 7.2.0, 7.3.0, 7.4.0
Windows PowerShell 5.1.0.0

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

Subscribes to an event on an object.

C++
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);

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

PowerShell SDK 7.4.0 et autres versions
Produit Versions
PowerShell SDK 7.2.0, 7.3.0, 7.4.0
Windows PowerShell 5.1.0.0

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

Subscribes to an event on an object.

C++
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);

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

PowerShell SDK 7.4.0 et autres versions
Produit Versions
PowerShell SDK 7.2.0, 7.3.0, 7.4.0
Windows PowerShell 5.1.0.0

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

Subscribes to an event on an object.

C++
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);

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

PowerShell SDK 7.4.0 et autres versions
Produit Versions
PowerShell SDK 7.2.0, 7.3.0, 7.4.0
Windows PowerShell 5.1.0.0