PowerShell: Convert .ps1 Files to .exe Files
Have you ever dreamed of creating exe files out of your PowerShell scripts? If yes, read on. In this post I will show you how you can create exe files with a small and simple program called ps2exe.
PS2EXE
First of all you need a tool that converts PowerShell scripts to exe files. Download it here:
https://gallery.technet.microsoft.com/scriptcenter/PS2EXE-GUI-Convert-e7cb69d5
Sample Script “Cortana speaks”
Now I have prepared an example. It will make Cortana speak. Yes, you heard right, this time not Azure, Office 365 etc… finally something funny.
Here is an extract of the script. As you can see, I create the graphical menus with Windows.Forms.
Curious and interested? Download the full script here: cortana_for_exe.zip
Now our ps2exe program comes into play …
Converting ps1 files to exe files with ps2exe
The following one-liner creates an exe file from the ps1 file. Note that I also provide an icon for our newly created program.
ps2exe.ps1 C:\temp\cortana_for_exe.ps1 ` C:\temp\cortana.exe -noconsole -nooutput -iconfile "C:\temp\cortana.ico" -verbose
The result looks like this:
Aaaand action …
Fantastic! Have fun!
See also
PowerShell: Show hidden properties from an Object
Microsoft 365: List all Mailbox Forwarding Rules (Server)
powershell,virtualization,01. +++++,windows
via SID-500.COM https://sid-500.com
July 31, 2020 at 04:21PM
Patrick Gruenauer