User Rating: 5 / 5

Star ActiveStar ActiveStar ActiveStar ActiveStar Active

In this article I will show four Script Packager options available for converting a non-GUI PowerShell script to a packaged executable that can be run from a console shell.

The "Packager" option is available under the "Deploy" ribbon tab in the PowerShell Studio and PrimalScript editors:


Pkg Ribbon 2019 06 18 17 56 27

Let’s take a look at the following script engine options:

  • SAPIEN PowerShell Vx Host (Command Line)
  • SAPIEN PowerShell Vx Host (Windows Application)
  • SAPIEN PowerShell Vx Host (Windows)
  • SAPIEN PowerShell Vx Host (Silent)

Pkg SrciptEngLista 2019 06 19 12 56 46

I will create the package script executable for each of the above options and check their behavior when running them from the console.

Sample WMI Script

The following PowerShell script uses WMI classes to retrieve some system information and display the results in the console.

The script has two parameters:

  • A "-ComputerName" parameter which can handle one or more string values.
  • A "-Help" parameter so it can display the Help information about the executable.

See the script below:

Pkg Code01 2019 06 21 16 37 24

Pkg Code02 2019 06 21 16 38 08

Pkg Code03 2019 06 21 16 39 05

The If-Statement logic will determine how the executable acts based on the selected parameter. It will include the necessary string manipulation to convert the string value to an array object if necessary.

Because argument values cannot be a .NET object type, all values passed to the parameters need to be defined as string.

The script also includes a function that will write entries to the system Application Event Log.

Script Engine Options


SAPIEN PowerShell Vx Host (Command Line)

This option will turn the script into a command line executable file that can be run from the console prompt. Also, it can display the command prompt window when executed directly.

To create the script executable, here are the steps to follow using the "Packager Settings".

Pkg Setting1 2019 06 24 17 45 11

For more detailed information, reference this article.


  • Script Engine – Select "SAPIEN PowerShell Vx Host (Command Line)"

    Pkg ScriptEngine 2019 06 18 18 33 40Notice that each script engine highlighted will provide a description and preview.

  • Output Settings – Enter the executable filename.

    Pkg OutSetting 2019 06 18 18 35 34

  • Execution Restrictions – Restrict the use of the script executable to specific Operating Systems.

  • Version Information – Add information about the script executable.

  • Build Commands – Include any Pre-build and/or Post-build commands to be used while preparing the script executable.

After completing the "Packager Settings", select "Build" to generate the script executable. The progress of the build will be display in the "Tool Output" panel.

Pkg Build 2019 06 18 18 50 17

kg Output 2019 06 18 18 57 05

We are now ready to open a console prompt and run the script executable file. But first, let’s run the following command to display the help information using the "-Help True" parameter.

PS > .\Get-SystemInfo.exe -Help True

Pkg exeHelp 2019 06 19 10 22 08

Next, to get some system information we will use the "-ComputerName" parameter:

PS > .\Get-SystemInformation -ComputerName "SAPIEN01,"

Pkg Cli2Exe 01 2019 06 21 17 36 27

The results will be displayed in the console and the system information will be added as an entry in the system Application Event Log.

EventLog CustomEntry 2019 06 21 17 43 58

SAPIEN PowerShell Vx Host (Windows Application)

This script engine option will build the script executable that will run as a Windows application.

Pkg ScriptEngine2 2019 06 19 10 46 45

Complete the "Packager Settings" sections as shown above, and then select the "Packager" > "Build" option to create the script executable file.

Next, in the console run the script executable with the "-Help True" parameter to display the Help information:

PS > .\Get-SystemInfo.exe -Help True

Pkg exeHelp2 2019 06 19 11 11 41

Then, use the "-ComputerName" parameter to get some system information:

PS > .\Get-SystemInformation -ComputerName "SAPIEN01,"

Pkg Cli2WinApp02 2019 06 21 17 52 27

Notice that all results will be displayed inside the Windows Application, and the system information found will be added as an entry in the system Application Event Log.


SAPIEN PowerShell Vx Host (Windows)

This option will build the script executable that will run a Windows Dialog box for displaying both input and output values.

Pkg ScriptEngine3 2019 06 19 11 39 39

After completing the steps for building the script executable file it will be ready to run in the console.

Let’s run the script executable and use the "-Help True" parameter to display the help information:

PS > .\Get-SystemInfo.exe -Help True

Pkg exeHelp3 2019 06 19 11 49 07

Now, using the "-ComputerName" parameter to display system information, each of the system object properties found will show a dialog box for each one.

PS > .\Get-SystemInformation -ComputerName ""

Pkg exeComp3 2019 06 19 11 55 06

And again, the script will write the system information as an entry in the system Application Event Log.


SAPIEN PowerShell Vx Host (Silent)

This script engine option will suppress any output sent to the console, and no window is displayed when executed directly. 

In the script sample, using the "-Help True" parameter, the help output is suppressed which makes the parameter useless.

Using the "-ComputerName" parameter, the system information output is also suppressed, except when it sends the results to the system Application Event Log.

Pkg CliSilent 2019 06 21 18 07 50

In Summary

The "Script Engines" options demonstrated above are available in both PowerShell Studio and PrimalScript.

Use either the "SAPIEN PowerShell Vx Host (Command Line)" or "SAPIEN PowerShell Vx Host (Windows Application)" for creating an executable using a PowerShell script. On the other hand, there could be some opportunities for using the "SAPIEN PowerShell Vx Host (Windows)" and "SAPIEN PowerShell Vx Host (Silent)".

Just be creative!

Sample Scripts can be downloaded:

Resource Information

If you have questions about our products, please post in our support forum.
For licensed customers, use the forum associated with your product in our Product Support Forums for Registered Customers.
For users of trial versions, please post in our Former and Future Customers - Questions forum.
Copyright © 2024 SAPIEN Technologies, Inc.