Technical Anshu
Tutorials Blog
PowerShell to EXE Guide

Convert a PowerShell Script to EXE Complete Guide With PS2EXE

You wrote a script that fixes a problem in ten seconds - but the people who need it will not open PowerShell, will not change an execution policy, and will not run a text file. Convert it into one EXE they can double-click. Here is the complete conversion, done right, with its limits stated plainly.

By Technical AnshuWindows 10 / 116 minute read
Watch the video to see the script converted and run on screen, step by step

Every Windows admin has a folder of brilliant little scripts nobody else can use. The script is fine; the packaging is the problem. A .ps1 file opens in Notepad when double-clicked, triggers policy warnings when it does run, and looks like a virus to a non-technical user. Converting it to an EXE with the free PS2EXE module fixes the packaging in about a minute. This page is the whole job in order: what conversion really does, the install, the command, the options that matter, and the testing that keeps you honest.

Windows PowerShell - converting a script
PS C:\Scripts> Install-Module -Name ps2exe PS C:\Scripts> Invoke-PS2EXE -inputFile ".\DiskCleanup.ps1" -outputFile ".\DiskCleanup.exe" PS C:\Scripts> .\DiskCleanup.exe
The whole conversion in three lines - install the free PS2EXE module once, convert, run. Command output shown is an example.
1

What Converting Actually Does

A PowerShell script is a text file. It needs PowerShell to open it, the right execution policy to run it, and a user who is not scared of a blue window full of text. A converted EXE removes all three frictions: the user double-clicks one file, exactly like any other program.

Be clear about what the tool does under the hood. PS2EXE, the free module this guide uses, wraps your script inside a small .NET program. The script text travels inside the EXE in encoded form, and when the EXE runs, it hands that script to the PowerShell engine built into Windows. Nothing is compiled into machine code, and the script is not turned into a secret - a later page in this set covers that limit in full.

That wrapper is still genuinely useful. It is the difference between sending a colleague a text file with six instructions and sending them one button that just works.

2

Step 1 - Test the PS1 Until It Is Boring

Never convert an untested script. The EXE hides the console and the error stream in ways that make debugging slow, so every bug must be found while the script is still a plain .ps1.

  1. Run the script as a normal user and as an administrator
  2. Run it on a machine that is not your own, if you can - paths and drives differ
  3. Feed it the wrong input once, on purpose, and watch what it does
  4. Only when it behaves the same way every time, convert it
3

Step 2 - Install the PS2EXE Module Once

PS2EXE is published on the PowerShell Gallery by its author, Markus Scholtes, and it is free. You install it once on your own PC; the people who receive the EXE install nothing.

  1. Open PowerShell and run Install-Module -Name ps2exe
  2. The first time, PowerShell may ask you to trust the PSGallery repository - answer Yes if you started the install yourself
  3. If module installs are blocked, allow them for your own session with Set-ExecutionPolicy -Scope CurrentUser RemoteSigned and understand you are changing a safety setting on your own account only

There is also a graphical front end, Win-PS2EXE, which shows every option as checkboxes and fields. It produces exactly the same EXE as the command line - use whichever you find clearer.

4

Step 3 - Run the Conversion

The basic command names an input script and an output file:

  1. Invoke-PS2EXE -inputFile ".\DiskCleanup.ps1" -outputFile ".\DiskCleanup.exe"
  2. The shorter alias ps2exe accepts the same parameters
  3. Add -noConsole if the script shows a window or form and you do not want a black console window behind it
  4. Add -requireAdmin if the script changes system settings, so Windows asks for elevation at launch instead of the script failing halfway
  5. Add -iconFile ".\tool.ico" plus -title, -product, -company and -version if the file will be shared - these fill the Details tab of the file properties

The video linked on this page walks through the conversion on screen; the options above are the same ones it uses, and the rest of this guide set explains each of them in depth.

5

Step 4 - Test the EXE Like a Stranger

A converted EXE is a new program as far as Windows is concerned. Test it the way its real user will meet it:

  1. Copy it to a different folder and run it by double-clicking, not from your PowerShell window
  2. Run it without administrator rights first, even if you built it for admin tasks, to see the failure honestly
  3. Watch for the antivirus and SmartScreen reactions and fix them properly - there is a full page on that in this set
  4. Keep the .ps1 source. The EXE is only a build output; every future edit starts from the script
The two honest limits of every script-to-EXE tool: the source inside the EXE can be read back by anyone determined enough, so never hide a password in a converted script; and a fresh unsigned EXE often worries antivirus software until it earns reputation or gets signed. Both topics have their own full guides in this set.

Watch the Complete Process in the Video

Watch the complete conversion in the video - module install, the GUI and command routes, and the finished EXE running.

Watch Full Video
Frequently Asked Questions

Does the target PC need PowerShell installed to run the converted EXE?

It needs the PowerShell engine that ships inside Windows itself, which Windows 10 and 11 carry by default. The user does not install anything and never opens PowerShell - the EXE starts the engine in the background and hands it your script.

Is the converted EXE a real compiled program?

Not in the C or C sharp sense. PS2EXE wraps your script text, encoded, inside a small .NET host program. When the EXE runs, the host feeds your script to the Windows PowerShell engine. The behaviour is identical to running the .ps1 - the packaging is what changes.

Can I convert a script for free, or is PS2EXE paid?

PS2EXE is free. It is a community module published on the PowerShell Gallery by Markus Scholtes, installed with Install-Module -Name ps2exe. Commercial packagers exist, but for the standard conversion job the free module is the tool used in the video and in this guide.

This guide is based on the Technical Anshu PowerShell to EXE video - Stuck on any step? Ask in the video comments and you will get a reply there.