PowerShell

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

Anmerkung 2020-07-31 165208

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.

Anmerkung 2020-07-31 165500

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:

Anmerkung 2020-07-31 170129

Aaaand action …

Anmerkung 2020-07-31 170205

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

Tagged as: ,

4 replies »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.