# Calling PowerShell function from the BeforeAction with parameters

**URL:** https://www.finalbuilder.com/forums/t/calling-powershell-function-from-the-beforeaction-with-parameters/2239
**Category:** Discussion
**Created:** [January 15, 2014, 2:35am UTC](https://www.finalbuilder.com/forums/t/calling-powershell-function-from-the-beforeaction-with-parameters/2239 "2014-01-15T02:35:24Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![efridman](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/e/a88e57/32.png) [@efridman](https://www.finalbuilder.com/forums/u/efridman)
#### Post date: [January 15, 2014, 2:35am UTC](https://www.finalbuilder.com/forums/t/calling-powershell-function-from-the-beforeaction-with-parameters/2239/1 "2014-01-15T02:35:24Z")

</div>

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 ?

---

<div class="post-metadata">

### Author: ![nevar](https://www.finalbuilder.com/forums/letter_avatar_proxy/v4/letter/n/c4cdca/32.png) [@nevar](https://www.finalbuilder.com/forums/u/nevar)
#### Post date: [January 15, 2014, 11:32am UTC](https://www.finalbuilder.com/forums/t/calling-powershell-function-from-the-beforeaction-with-parameters/2239/2 "2014-01-15T11:32:51Z")

</div>

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

Option One:&nbsp;

Global Script   
function GlobalBeforeAction{param($MyArg1, [bool] $MyArg2)$MyArg1.SendLogMessage(“Global Script Called”)}  
  
BeforeAction   
GlobalBeforeAction $Action $SkipAction&nbsp;  
  
  

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.
