Parameter use broken on compiled scripts ?

This forum can be browsed by the general public. Posting is limited to current SAPIEN license holders with active maintenance and does not offer a response time guarantee.
Forum rules
DO NOT POST SUBSCRIPTION NUMBERS, LICENSE KEYS OR ANY OTHER LICENSING INFORMATION IN THIS FORUM.
Only the original author and our tech personnel can reply to a topic that is created in this forum. If you find a topic that relates to an issue you are having, please create a new topic and reference the other in your post.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
User avatar
Aarhus Kommune-1
Posts: 2
Joined: Wed Mar 14, 2018 5:22 am

Parameter use broken on compiled scripts ?

Post by Aarhus Kommune-1 » Mon May 06, 2019 3:09 am

Hi.

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 :

Code: Select all

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
Running from powershell prompt with parameters : .\scriptname.ps1 -Action Install/Remove , it works fine.
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

User avatar
Alexander Riedel
Posts: 7057
Joined: Tue May 29, 2007 4:43 pm

Re: Parameter use broken on compiled scripts ?

Post by Alexander Riedel » Mon May 06, 2019 3:35 am

Make a backup of the current PSBuild.exe in your PrimalScript install folder.
Replace with the file attached here and see if that helps.
Attachments
PSBuild.zip
(184.95 KiB) Downloaded 24 times
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
Aarhus Kommune-1
Posts: 2
Joined: Wed Mar 14, 2018 5:22 am

Re: Parameter use broken on compiled scripts ?

Post by Aarhus Kommune-1 » Mon May 06, 2019 5:14 am

Seems to fix it for V3 & V5 commandline option, but an error is still generated for the SAPIEN Script Host (Commandline) option (look below) - maybe i'm using this option wrong , earlier your compilers had an engine running your own flavour of PowerShell - but the manual doesn't explain this mode in details.

C:\Temp>parametertest.exe -Action Install
Error(1): En sætning var ventet : Translation = A sentence was expected

User avatar
Alexander Riedel
Posts: 7057
Joined: Tue May 29, 2007 4:43 pm

Re: Parameter use broken on compiled scripts ?

Post by Alexander Riedel » Mon May 06, 2019 7:27 am

We have no "own flavor of PowerShell", so I am sorry but I do not understand what that would mean.
The SAPIEN Script Host engines are not for PowerShell. They are for ActiveX languages and since they don't say PowerShell (as opposed to those that do say that), we thought that was obvious that they are not for use with PowerShell. :D
Alexander Riedel
SAPIEN Technologies, Inc.