Requirements and restrictions to run PowerShell scripts inside the Batchcontroller:
PowerShell version:
The PowerShell version on the system where the BatchController is running must be at least PowerShell version 7.6.1, recommended is the newest 7.6.* version.
Within PowerShell the version is displayed by running:
$PSVersionTable
Execution Policy:
The execution policy need to be set to RemoteSigned with the scope of LocalMachine
This can be achieved by running the following command in PowerShell with Administrators rights:
set-executionpolicyremotesigned-ScopeLocalMachine
For more information about execution policies, see execution policy on the Microsoft website.
MyInvocation:
Usage of "$MyInvocation" inside the scripts and Avanade script libraries must be removed, as not all properties are
filled because of limits from Microsoft automation. For example when you have the following code:
When run inside the Batchcontroller, the environment variable "AMTJOBNAME" is set to the active script.
Exit statement:
Any "Exit" statement must also set a PowerShell variable "$Global:AmtExitCode" for the Batchcontroller to read it
correctly:Change from: