Tuesday, October 31, 2017

Output of event handler script blocks goes to the event object

One user was wondering how to output from a script block registered to an event to the script that set the event handler. Register-ObjectEvent returns a job object corresponding to the new event, which the setting script can store. That object has an Output property that is an array of the values produced. When the event handler block returns a value (just like normal functions do), PowerShell stashes it in the Output array.

No comments:

Post a Comment