Calling PowerShell function from the BeforeAction with parameters

I’m probably missing something

I have a PowerShell function in the global script which should get parameters when calling it from the BeforeAction

What should be the syntax for that in the global script and in the BeforeAction ?

Hi EF,

There are a few ways in which you can do this.

Option One: 

Global Script
function GlobalBeforeAction{param($MyArg1, [bool] $MyArg2)$MyArg1.SendLogMessage(“Global Script Called”)}

BeforeAction
GlobalBeforeAction $Action $SkipAction 


Option Two:

Global Script
function GlobalBeforeAction{$Action.SendLogMessage(“Global Script Called”)}

BeforeAction
GlobalBeforeAction

The thing to keep in mind with both approaches is that the global scripts are included into each action script, and action event script. Therefore the parameters which are passed to event scripts are accessible to all global scripts. Therefore you can safely use $Action, in this case and for most other action script events. Note that the $SkipAction parameter however is only present when running a BeforeAction.