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 created 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!
Credits
Credits go to Ingo Karstein and Markus Scholtes for developing ps2exe. THANK YOU!
See also
PowerShell: Show hidden properties from an Object
Microsoft 365: List all Mailbox Forwarding Rules (Server)
Categories: PowerShell
Hi Patrick,
the technet link is broken, but there are two relevant GitHub links:
https://github.com/MScholtes/PS2EXE
https://github.com/MScholtes/Win-PS2EXE
LikeLike