n most scenarios it’s enough to use the PowerShell script as is.
But
- sometimes there is some sensitive data in the script you don’t want to expose
- the executable is run hidden (doesn’t show the script on the screen while logging in)
To turn a PowerShell script into an Executable
- Open a PowerShell window (in Administrator mode)
- Run
Install-Module ps2exe
3. Run
Invoke-PS2EXE C:\ProgramData\Cameyo\StartupBefore.ps1 C:\ProgramData\Cameyo\StartupBefore.exe
In the case of a startup script, don’t forget to remove the PowerShell script, otherwise the script will be executed twice
to add an icon ….
Invoke-PS2EXE .\StartleScript.ps1 StartleScript.exe -iconFile C:\Users\jfargion-admin\Downloads\erbc.ico
Invoke-PS2EXE .\StartleScript_noconsole.ps1 StartleScript.exe -iconFile C:\Users\jfargion-admin\Downloads\erbc.ico -noconsole -company 'ERBC-Group' -version '1.0' -noOutput -title 'ES0203 - Startle Script Tool' -copyright 'ERBC-Group by Jacques Fargion' -exitOnCancel
Ref: https://github.com/MScholtes/PS2EXE