Navigation:  Actions > Miscellaneous > PowerShell >

PowerShell Action Command Tab

Previous pageReturn to chapter overviewNext page

This tab of the PowerShell Action action configures information about the script to be run.


Command script: Specifies the script to invoke (required).  The filename of a file can be provided, or the contents of a script can be entered in the second field.



Single percent characters must be doubled (%%) to not be treated specially by Visual Build.  Strings within percent (i.e., %PATH%) will also be expanded by Visual Build if not escaped.
Bracket characters [ and ] normally denote a script expression to be inserted into a field; to insert literal brackets, use two bracket characters [[ or ]].
If Ignore special characters is checked, the above processing of special characters for macro references and script expressions will not be performed and escaping (doubling) will not be needed.
The exit code of the command processor will be stored in the RUNPROGRAM_EXITCODE temporary macro.


Use the following code to read or write global macros from a PowerShell script (to transfer information between Visual Build and your script):


# create app object

$app = New-Object -com VisBuildSvr.Application


# retrieve global macros

$global = $app.Macros(2)



# READ A VALUE FROM Visual Build

# Note: values can also be passed to the script via the Parameters field on the Input tab

# store a global macro value in a PowerShell variable

$val = $global.Item("ABC").Value


# echo the variable value (logged in Visual Build)




# WRITE A VALUE TO Visual Build

# create/update macro with two values delimited by tab

$global.Add("XYZ", "val1`tval2")


# save changes to global macros (accessible in the following steps in Visual Build)