Four stages turn a finished PowerShell script into a working EXE: test the script, install the free PS2EXE module, run one command (or click through the GUI), and test the result the way a user will. Each stage is short - the discipline is in not skipping the test stages.
People ask for the conversion command as if it were the whole job. It is one line in stage three of four. The stages before and after it - testing the script, then testing the EXE - are where conversions succeed or quietly fail. Here is the complete order, with the exact commands, ready to copy.
The conversion freezes your script into a program, so freeze a finished one. Run the .ps1 start to finish, on a normal account and an admin account, and read every line of its output. Any error you ship inside an EXE becomes ten times slower to diagnose, because the user sees a window close - or nothing at all - instead of an error message you can ask about.
Install-Module -Name ps2exeSet-ExecutionPolicy -Scope CurrentUser RemoteSigned on your own account, and note that you changed itThis install happens once, on the machine that builds EXEs. Target PCs need nothing.
Command line, one instruction:
Invoke-PS2EXE -inputFile ".\Cleanup.ps1" -outputFile ".\Cleanup.exe"ps2exe with the same parameters does the identical job-noConsole, -requireAdmin, -iconFile, -title, -versionPrefer clicking? Run Win-PS2EXE and the same choices appear as a form: pick the input file, the output file, tick the options, press Compile. The video on this page shows the graphical route being used, which is why most people start there - the output file is exactly the same either way.
Then file the pair together - script and EXE, same folder, same version in the name if your team is informal. When the script changes, re-run stage 3 and replace the EXE; never edit around a stale build.
Watch the video to see this exact sequence performed - install, GUI options, compile and run.
Watch Full VideoThat prompt appears the first time anyone installs a module from the PowerShell Gallery, and it is Windows asking you to confirm the source once. If you typed Install-Module -Name ps2exe yourself, answering Yes is the normal, expected step. If a random script ever asks you to trust a gallery you have never heard of, that is the time to stop.
Yes, if the questions are console prompts or Windows forms the script already shows. Keep the console version (do not use -noConsole) for prompt-based scripts, or the user will see nothing and the EXE will appear frozen while it waits for input it cannot receive.
No. Options change the package - console versus no-console hosts, embedded icon and version data all change the size slightly. What matters is behaviour: test the EXE you actually plan to ship, built with the exact options you plan to ship.