Specifying PowerShell Version for Before/After Scripts
IQService now supports specifying the PowerShell version to provide provisioning of Before/After nativeRules scripts to run under any Powershell version.
Note
PowerShell scripts requiring PowerShell version greater than 5.1 should have pwsh.exe
installed in the IQService host. Refer to Installing PowerShell on Windows for more information.
Following are the ways to specify versioning for PowerShell script with PowerShell version above 5.1:
-
Add a Program attribute in the rule as shown below:
<entry key="program" value="pwsh.exe" />
-
Add a statement
#Requires -Version 7.3 (Or any version greater than 5)
in the script in the first line of source-code. Refer to about_Requires for more information.
-
For PowerShell version above 5.1, the script will be executed with
pwsh.exe
instead ofpowershell.exe
. -
To run nativeRules scripts with PowerShell version 5.1 and before, the value of the Program attribute is by default
powershell.exe
. Ensure to mention the version you want in#Requires -Version
. If you do not mention#Requires -Version
in the script, the script will run under default PowerShell version of that IQService machine. -
Other functionality and access to XML object in
ObjectOrientedScript
will continue to work as before.