Product, version and build:
PrimalScript 2019 v7.4.127 x64
Powershell Studio 2019 v5.6.162 x64
on
Windows 10 v1809 (17763) x64
Having problems with running compiled scripts (Powershell) with parameters in above mentioned versions of your product, the following code is showing the problem :
- param
- (
- [Parameter(Mandatory = $true,Position = 1)][string]
- [ValidateSet('Install','Remove')]
- $Action
- )
- switch($Action){
- 'Install' {$RetValue = 'Commandline parameter value = Install'}
- 'Remove' {$RetValue = 'Commandline parameter value = Remove'}
- default {$RetValue = 'Commandline parameter value = Unknown'}
- }
- $RetValue | Out-Host
Compiled and from commandline with the same parameters , it fails with the following output :
C:\Temp>ParameterTest -Action Install
Line 30: At line:29 char:53
+ [Parameter(Mandatory = $true,Position = 1)][string]
+ ~
Missing closing ')' in expression.
At line:30 char:3
+ [ValidateSet('Install','Remove')]
+ ~
Array index expression is missing or not valid.
At line:30 char:3
+ [ValidateSet('Install','Remove')]
+ ~~~~~~~~~~~
Unexpected token 'ValidateSet' in expression or statement.
At line:32 char:1
+ )
+ ~
Unexpected token ')' in expression or statement.
At line:29 char:2
+ [Parameter(Mandatory = $true,Position = 1)][string]
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Unexpected attribute 'Parameter'.
This goes for generated executables both in 32bit and 64bit versions and have been testet with following deployment settings :
Microsoft Windows 32 and 64 Bit output files generated
Testet on :
SAPIEN PowerShell V5 Host (Commandline)
SAPIEN PowerShell V3 Host (Commandline)
SAPIEN Script Host (Commandline)
with STA Mode enabled , default manifest embedded and as Current User (being local admin)
Regards Henrik