Compile PowerShell scripts to exe

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:

  1. Open the script in PowerGUI Pro Script Editor,
  2. On the Tools menu, click Compile Script,
  3. Then specify the name and path for the exe file you want to create:

PowerShell Compiled scripts

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)

About these ads

26 Responses to “Compile PowerShell scripts to exe”


  1. 1 Klaus Graefensteiner August 22, 2011 at 2:13 pm

    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

  2. 4 chrisjwarwick August 22, 2011 at 4:26 pm

    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…

  3. 6 Jonas October 18, 2011 at 2:25 pm

    Is it possible to compile exe files with the basic version of Powergui?

  4. 8 Anonymous October 20, 2011 at 3:16 pm

    Is it possible (there’re any way(s)) to revert the code inside the exe back to Ps script?

  5. 9 Anonymous October 27, 2011 at 5:49 am

    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 :-)

  6. 11 Vineeth May 5, 2012 at 9:05 pm

    Reblogged this on VM.Blog. and commented:
    Good post on how to run PS scripts as “.exe”

  7. 12 Mark January 21, 2013 at 10:59 pm

    Is it possible to decompile the exe back to PS1 in order to view the source code?

  8. 14 Dirk February 11, 2013 at 2:18 pm

    Is it possible to add the Quest AD extension to this exe?

    • 15 Dmitry Sotnikov February 11, 2013 at 7:01 pm

      The cmdlets need to be installed on the target machine separately. If they are – you can obviously use them in the exe – just add the snapin in your code.

  9. 16 Geert April 4, 2013 at 1:58 pm

    If you compile your script to an exe this way, does the computer on which the file is executed need to have execution policy set to allow all?

    • 17 Dmitry Sotnikov April 4, 2013 at 6:48 pm

      I am actually no longer on the PowerGUI team – so I am not sure. You can give it a try – PowerGUI is now just a free download.

  10. 18 Anonymous April 4, 2013 at 8:39 pm

    Is there any way to have the .exe run from the x86 powergui. I am having a issue running the exe when trying to connect to a databse

    • 19 Dmitry Sotnikov April 6, 2013 at 5:10 am

      If you are on Windows x64 you should have both PowerGUI x64 and PowerGUI x86 installed. My understanding is that x86 PowerGUI will create x86 exe… However, I am not 100% sure. If this does not work – try asking in the forums at http://powergui.org

  11. 20 Flossie May 14, 2013 at 6:24 pm

    You shouldn’t have had any driving offences involving drugs or alcohol in the last three years. Your credit rating is definitely the most important thing in your financial life which means that you have to do everything in your capacity to have your rating higher. But what actually happens is this: they are betting against people that placed bets for the other team.

  12. 21 Mark May 15, 2013 at 2:57 am

    If you need to insure a car for short term duration,
    you can seek professional help. Online insurance agencies can be very helpful in
    getting you exactly the policy you need for your car insurance.
    ‘ You are going to want to double check this particular with a rep from your charge card company.

  13. 22 Oma May 23, 2013 at 6:28 am

    A police accident report will likely contain most of this information, but write it
    down anyway, if you’re able. In a casual conversation with my car insurance agent one day, she told me my rates would drop a lot after 3 years because those accidents would drop off my record. Suddenly what you once believed to be a great and honest relationship is now a big mess of confusion and hurt.


  1. 1 List Building Script | How Do I Build A List? Trackback on September 25, 2011 at 7:08 pm
  2. 2 List Building Script | How Do I Build A List? Trackback on September 26, 2011 at 8:30 am
  3. 3 PowerGUI 3.1 Released! « Dmitry’s PowerBlog: PowerShell and beyond Trackback on October 14, 2011 at 1:49 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s




My Recent Tweets

RSS My company’s blog

  • Meet our iPad2 Winner, Bruce Burke
    Last month we ran our first sweeps contest and received over 30,000 entries in just 4 weeks! Below is a screenshot of the Facebook entries: After announcing the winner, Bruce Burke, I decided to get in touch and find out more about him and how he is using Jelastic for his projects. Hi Bruce, thanks [...]The post Meet our iPad2 Winner, Bruce Burke appeared fi […]
  • MongoDB Master Slave Replication
    As we’ve already told you in our previous post about MySQL master-slave replication the database replication offers various benefits depending on its type and the options you choose, but the common benefit of replication is the availability of data when and where it is needed.  As a result, your customers will experience improved availability of replicated d […]
  • Integration with NetBeans IDE
    Like millions of developers out there we really love NetBeans IDE, which lets you quickly and easily develop Java desktop, mobile, and web applications, while also providing great tools for PHP developers. That’s why we have created a Jelastic plugin for this platform. With the new Jelastic plugin for NetBeans IDE, you can work with your development, [...]Th […]
  • New Version of Jelastic – 1.9.1 Launched
    Today we announced the launch of a major new version of Jelastic. The new version, 1.9.1, features a CRON scheduler, the ability to schedule database backups, new notifications about running out of resources and the latest versions of software stacks (including PostgreSQL 9.2.4). The newly launched Jelastic 1.9.1 includes: CRON job scheduler, Scheduled datab […]
  • Jelastic Released Commercially by innofield!
    Switzerland is well know for chocolate, their army knives and creating fabulous watches. Thanks to innofield,  the Swiss will forever be known as the providers of the first Swiss based PaaS solution with their Flow App Engine (powered by Jelastic). This week, innofield came out of beta and launched commercially with Jelastic 1.9.1. “As Platform-as-a-Service […]
  • Play 1 vs Play 2 Framework
    Today’s guest post comes to you from our friend and user, Dane Marcelo, JArchitect product manager. He points out some interesting differences between the Play 1 and the Play 2 frameworks. So, let’s dive into this great post! Play is an open source web application framework, written in Scala and Java, which follows the model–view–controller (MVC) architectur […]
  • Cloud Software Stacks Market Share: April 2013
    It’s that time where we can share with you the updated statistics on databases, Java and PHP application servers as well as Java and PHP version popularity. Last month was hot here at Jelastic: we launched Jelastic in the Netherlands with the most technically advanced hoster in the country – info.nl and in Switzerland with our very [...]The post Cloud Softwa […]

Legal

The posts on this blog are provided “as is” with no warranties and confer no rights. The opinions expressed on this site are mine and mine alone, and do not necessarily represent those of my former employer - Quest Software, or my current employer - Jelastic or anyone else for that matter. All trademarks acknowledged.

© 2007-2013 Dmitry Sotnikov

Pages

August 2011
M T W T F S S
« Jul   Sep »
1234567
891011121314
15161718192021
22232425262728
293031  

Follow

Get every new post delivered to your Inbox.

Join 65 other followers

%d bloggers like this: