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)

Subscribe by email


I like this feature.
An extremely cool enhancement would be allow for other payloads that get compiled into the executable. I was thinking about assemblies and native executables.
I have a PowerShell script that uses cURL.exe that I need to distribute as one executable.
Klaus
Klaus, try adding cURL.exe as a “PowerShell script” Dependency – I have not tried this myself but it should probably work…
Excellent facility. I’ve had complications before trying to talk someone through starting PowerShell, setting execution policy etc etc – so this could simplify things in those cases.
Of course, you can do this natively (and WPK, the pre-”ShowUI” code from James Brundage, let you produce exe’s from scripts quite easily) – but this is seamless.
I assume you need PowerShell installed wherever the .exe is going to run – so I gues it could be a problem in some cases targetting legacy (e.g. XP) machines…
Chris, yes, powershell.exe is indeed required – your assumptions are correct.
Is it possible to compile exe files with the basic version of Powergui?
Jonas, unfortunately, at the moment this is a Pro feature.
Is it possible (there’re any way(s)) to revert the code inside the exe back to Ps script?
a very nice feature.
however you need to have all the cmdlets on the featured machine to i guess. it do not compile the cmdlets needed into the exe file (atleast not on my tests)
so it is not only powershell.exe that is needed but also the cmdlets you want to use on the machine running the compiled file ?
or am i doing something wrong here
You should be able to add the modules that your script needs using the Dependencies button. If this for some reason does not work for you – please post the repro steps to our forum at http://powergui.org