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 LICENSE NUMBERS, ACTIVATION 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.
This topic is 4 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
User avatar
Aarhus Kommune-1
Posts: 2
Last visit: Thu Dec 12, 2019 10:57 am

Parameter use broken on compiled scripts ?

Post by Aarhus Kommune-1 »

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 :
  1. param
  2. (
  3.     [Parameter(Mandatory = $true,Position = 1)][string]
  4.     [ValidateSet('Install','Remove')]
  5.     $Action
  6. )
  7.  
  8.     switch($Action){
  9.     'Install' {$RetValue = 'Commandline parameter value = Install'}
  10.     'Remove' {$RetValue = 'Commandline parameter value = Remove'}
  11.     default {$RetValue = 'Commandline parameter value = Unknown'}
  12.     }
  13.     $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: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Parameter use broken on compiled scripts ?

Post by Alexander Riedel »

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 158 times
Alexander Riedel
SAPIEN Technologies, Inc.
User avatar
Aarhus Kommune-1
Posts: 2
Last visit: Thu Dec 12, 2019 10:57 am

Re: Parameter use broken on compiled scripts ?

Post by Aarhus Kommune-1 »

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: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: Parameter use broken on compiled scripts ?

Post by Alexander Riedel »

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.
This topic is 4 years and 10 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.