Skip to main content
Print

Powershell to EXE –

Method 1: Using the PS2EXE Module (Recommended)

This method packages your script into a lightweight executable wrapper. You can do this entirely via the command line or use its built-in graphical interface (GUI).

Step 1: Install PS2EXE

Open PowerShell as an Administrator and run the following command to download the module from the Microsoft PowerShell Gallery:

powershell

Install-Module -Name ps2exe -Scope CurrentUser

Use code with caution.

(If prompted to trust the repository, type Y or A for Yes/All).

Step 2: Convert Your Script

Option A: Using the Command Line (Fastest)
Run the Invoke-ps2exe command by specifying your source file and your desired output path:

powershell

Invoke-ps2exe -inputFile "C:\path\to\script.ps1" -outputFile "C:\path\to\program.exe"

Use code with caution.

  • 💡 Useful Flags:
    • Add -noConsole if your script has a graphical user interface (GUI) and you want to prevent the black PowerShell console window from popping up.
    • Add -iconFile "C:\path\to\icon.ico" to give your executable a custom icon.

Option B: Using the Graphical Interface (Easiest)
If you prefer a visual interface to select files and configure settings, type this into PowerShell:

powershell

Win-PS2EXE

Use code with caution.

A window will pop up allowing you to easily browse for your .ps1 file, pick an output destination, assign an icon, and check configuration boxes before compiling.


Method 2: Using the Built-In Windows Tool (IExpress)

If you are on a restricted machine where you cannot install external PowerShell modules, you can use IExpress, a legacy packaging utility built into Windows.

  1. Press Win + R, type iexpress, and hit Enter (Run as Administrator).
  2. Choose Create new Self Extraction Directive file and click Next.
  3. Select Extract files and run an installation command.
  4. Package Title: Enter a name for your application.
  5. Confirmation/License: Select “No prompt” and “Do not display a license”.
  6. Packaged files: Click Add and select your .ps1 script.
  7. Install Program to Launch: In the Install Program box, paste the following command (replace myscript.ps1 with your actual file name):cmdpowershell.exe -ExecutionPolicy Bypass -File myscript.ps1 Use code with caution.
  8. Show window: Select Hidden if you don’t want a command window flashing.
  9. Finished message: Select “No message”.
  10. Package Name and Options: Click Browse to choose where to save your final .exe file. Check “Hide File Extracting Progress Animation”.
  11. Choose “No save” for the SED file, and advance to the final screen to compile your executable.