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.
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.
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.
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.
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.
Install-Module -Name ps2exeSet-ExecutionPolicy -Scope CurrentUser RemoteSigned and understand you are changing a safety setting on your own account onlyThere 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.
The basic command names an input script and an output file:
Invoke-PS2EXE -inputFile ".\DiskCleanup.ps1" -outputFile ".\DiskCleanup.exe"ps2exe accepts the same parameters-noConsole if the script shows a window or form and you do not want a black console window behind it-requireAdmin if the script changes system settings, so Windows asks for elevation at launch instead of the script failing halfway-iconFile ".\tool.ico" plus -title, -product, -company and -version if the file will be shared - these fill the Details tab of the file propertiesThe 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.
A converted EXE is a new program as far as Windows is concerned. Test it the way its real user will meet it:
.ps1 source. The EXE is only a build output; every future edit starts from the scriptWatch the complete conversion in the video - module install, the GUI and command routes, and the finished EXE running.
Watch Full VideoIt 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.
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.
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.