Is it possible to access the Event arguments in the -Action scriptblock of the Register-ObjectEvent cmdlet? And if yes, how?
views:
164answers:
1
+2
A:
Yes. The EventArgs
object is available inside the Action script block as a magical variable called $Event
. This is what get-help Register-ObjectEvent -detail
has to say:
The value of the Action parameter can include the $Event, $EventSubscriber, $Sender, $SourceEventArgs, and $SourceArgs automatic variables, which provide information about the event to the Action script block. For more information, see about_Automatic_Variables.
dangph
2009-12-10 10:01:08