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 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 6 years and 8 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
JMS_PT
Posts: 73
Last visit: Mon Sep 24, 2018 10:26 am

PS Executables

Post by JMS_PT »

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

Re: PS Executables

Post by Alexander Riedel »

"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
Last visit: Mon Sep 24, 2018 10:26 am

Re: PS Executables

Post by JMS_PT »

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
Last visit: Mon Sep 24, 2018 10:26 am

Re: PS Executables

Post by JMS_PT »

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

Thank you.
User avatar
Alexander Riedel
Posts: 8478
Last visit: Tue Mar 26, 2024 8:52 am
Answers: 19
Been upvoted: 37 times

Re: PS Executables

Post by Alexander Riedel »

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.
This topic is 6 years and 8 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.