Friday, July 3, 2026

[Powershell] Powershell script compilation (Turning PS1 into EXE)

 C:\tmp>powershell -File hello.ps1

Hello World


C:\tmp>powershell -Command "Install-Module -Name ps2exe -Scope CurrentUser"


NuGet provider is required to continue

PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet

 provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or

'C:\Users\Chaoyi-H\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by

running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install

and import the NuGet provider now?

[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): Y


Untrusted repository

You are installing the modules from an untrusted repository. If you trust this repository, change its

InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from

'PSGallery'?

[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): A


C:\tmp>Powershell -Command "Invoke-ps2exe -inputFile "hello.ps1" -outputFile "Hello.exe""

PS2EXE-GUI v0.5.0.34 by Ingo Karstein, reworked and GUI support by Markus Scholtes



Reading input file C:\tmp\hello.ps1

Compiling file...


Output file C:\tmp\Hello.exe written


C:\tmp>Hello.exe

Hello World