PS Executables

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
JMS_PT
Posts: 73
Joined: Wed Dec 09, 2015 4:10 am

PS Executables

Post by JMS_PT » Fri Jun 30, 2017 2:52 pm

Hi I m trying to build a executable with PrimalScript that will accept parameters input. The goal is that the exe will call internal functions depending of the parameters passed to it.
I used this link "https://www.sapien.com/blog/2015/11/30/ ... able-file/" as reference.
When I try to test I get some errors where the functions are not recognized. Do you have some sample script that uses multiple called functions inside it that can be used in a script converted to exe?

My Example:

Param
(
[Parameter(Mandatory = $true)]
[String]$Word,
[int]$Number = 1
)

Get-SomethingX -Number $Number


Function Get-SomethingX()
{
Param
(
[Parameter(Mandatory = $true)]
[int]$Number = 1
)

Get-SomethingXX -Number $Number
}

Function Get-SomethingXX()
{
Param
(
[Parameter(Mandatory = $true)]
[int]$Number = 1
)
Get-SomethingXXXX -Number $Number
}

Function Get-SomethingXXXX()
{
Param
(
[Parameter(Mandatory = $true)]
[int]$Number = 1
)

1..$Number | foreach { "$Word" * $_}
}
Thank you.

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

Re: PS Executables

Post by Alexander Riedel » Fri Jun 30, 2017 3:06 pm

"I get some errors ..."
If you get errors, please always state the actual error messages. We cannot really guess what you see. Thanks!
Alexander Riedel
SAPIEN Technologies, Inc.

User avatar
JMS_PT
Posts: 73
Joined: Wed Dec 09, 2015 4:10 am

Re: PS Executables

Post by JMS_PT » Fri Jun 30, 2017 3:10 pm

Error

ERROR: Get-SomethingX : The term 'Get-SomethingX' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the nam
ERROR: e, or if a path was included, verify that the path is correct and try again.

I solve it by placing the Get-SomethingX at the end of the script.

User avatar
JMS_PT
Posts: 73
Joined: Wed Dec 09, 2015 4:10 am

Re: PS Executables

Post by JMS_PT » Fri Jun 30, 2017 3:12 pm

Do you have any pratical samples that I can look at?

Thank you.

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

Re: PS Executables

Post by Alexander Riedel » Fri Jun 30, 2017 3:18 pm

You are attempting to use a function before it is defined. Move your call below the function declarations.
FWIW, that has nothing to do with the packager or it being an exe. That is just basic PowerShell.
Alexander Riedel
SAPIEN Technologies, Inc.