This has been asked for many times. But it's unlikely to get done.
First, even if MS were to do it, it would almost certainly end up compiled as IL (Intermediate Language), like all .NET binaries. These are convertible back to code with tools like reflector. So an execution is not going to be very helpful in terms of 'security'.
Recently I stumbled upon an executable that appeared to be a PowerShell script converted into an executable. I was curious to the actual script so I decided to have a look and see how I could convert the executable back into PowerShell. Having seen similar techniques to turn vb scripts and java jar’s into executables.
My suggestion to you is to NOT obfuscate your code, but to digitally sign it and set the execution policy on the Win7 boxes to run signed code only. That way, any 'fixes' your users do immediately invlidated the digital signature and since they can't re-sign it, their changes can't really be run.
At the end of the day, hire folks you can trust, and trust the folks you hire.
Graphical front end to PS1-to-EXE-compiler PS2EXE.ps1
Author: Markus Scholtes
Version: 1.0.0.1
Date: 2019-07-01
With PS2EXE.ps1 originally created by Ingo Karstein you can compile Powershell scripts to real Windows executables. Win-PS2EXE is a small graphical front end to the script.
Features and restrictions:
- Win-PS2EXE does not support all parameters of PS2EXE.ps1
- WPF application that compiles without Visual Studio or MSBuild on every Windows with .Net 3.5x or .Net 4.x
- only one source file
- drag'n'drop for file names
- separate .Net 4.x and .Net 3.5x versions (since .Net 3.5x do not allow uncompiled event handlers in XAML)
Screenshot:
How to compile:
Run Compile.bat (in a .Net 3.5x environment use the version in folder DotNet3.5).
How to use:
Ensure PS2EXE.ps1 is in the same directory as Win-PS2EXE.exe.
Compile Ps1 To Exe Download
Start Win-PS2EXE.exe and fill in the desired fields (only Source file is mandatory).
Compile Powershell Script To Exe
Click Compile, a powershell window opens and your powershell script will be compiled to an executable.