Script compilation to executable files is one of the features we have added in PowerGUI Pro 3.0.
You would likely want to use compile a script when you want to share it in the enterprise environment and you are not sure whether the other person is comfortable running scripts or you simply don’t want risking someone modifying the code.
To compile a PowerShell script:
- Open the script in PowerGUI Pro Script Editor,
- On the Tools menu, click Compile Script,
- Then specify the name and path for the exe file you want to create:
The additional options you get are:
- Show or hide the PowerShell Console window when executing the script,
- Automatically close or keep the console window (if you do want to show it),
- Protect the script source code by obfuscating it using a password you specify,
- Add other PowerShell scripts to the exe (if you have script which your main script is using).
[UPDATE] If your script access parameters – so will the exe file it generates. So for an executable generated from a script like:
param ($MyParam1, $MyParam2) "MyParam1: $MyParam1""MyParam2: $MyParam2"
You may use a command line like:
c:\Generated.exe -Arguments -MyParam2 "Value2" -MyParam1 "Value1"
To try this feature, you can install a trial version of PowerGUI Pro from here.
(Screenshot taken from the original PowerGUI 3.0 announcement which lists a lot of other great features we shipped in that release)