Powershell: feature request: official open source tool to compile powershell script to EXE

Created on 28 Aug 2016  路  8Comments  路  Source: PowerShell/PowerShell

Please create an official tool to "compile" and "obfuscate" powershell "script" to .exe

people have been asking about third party tools to do this since years.
http://stackoverflow.com/questions/3759456/create-a-executable-exe-file-from-powershell-script
https://stackoverflow.com/questions/48338017/convert-powershell-script-to-exe

we eagerly await to have an microsoft's official open source tool to compile powershell scripts to exe ??

Issue-Enhancement Up-for-Grabs WG-Engine

Most helpful comment

Hi @zaxebo1 a few quick thoughts!

  • Have you considered script signing, if your concern is modification of scripts?
  • Have you considered hiring, or training your team(s) to use a core tool that anyone (IMHO) in a Microsoft ecosystem should be familiar with?

No offense intended, just offering some alternatives that might work, given that this seems a (IMHO) very low priority.

Cheers!

All 8 comments

Although it would be useful for some I think this functionality should exist outside of the core Powershell runtime. The desired functionality is already provided by several Windows Powershell IDEs such as PowerGUI and PowerShell Studio. If anything a community module could provide the same functionality. There is also the security concern with executables. Personally I prefer to review any script that I might run before hand which an executable cannot provide.

External tools simply wrap scripts, they don't actually compile anything.

Proper compilation support would require support from the engine.

It's certainly something that can be implemented as we do JIT compile code today, but there's still a lot of work to persist the IL we generate because the generated IL depends on live data structures. A compiled PowerShell script would need to recreate those live data structures to work properly.

Also note that a compiled PowerShell script would still require installing PowerShell and all of the modules the script depends on. Compilation does not eliminate the need for those dependencies.

@thezim : when i receive a powershell script as a senior system administrator, then i would like to myself review the script source code , and decide to whether to get it executed on some systems.(same as you suggested)

BUT once i decided on the script and gave it to very low tech-people/junior support staff for geographically remote - mostly disconnected networks, then i would like to give it in compiled exe format , so that the people i gave it to, do not change it knowingly/unknowingly; and hence (as a senior administrator) i am in total control of what is being executed there(on geographically remote - mostly disconnected networks) is not the modified script, but what is executed there is my script without any modification.

Hence, in some cases source code form of script is useful and in some cases compiled form of script is useful

additionally, script compilation and "obfuscation" support will give me another reason to push powershell in my company for shell scripting, as compared to bash/zsh etc shell scripting languages which do not support compilation.

This will be major selling point of powershell(compared to bash) to CTOs even on linux, if they see that scripts can be powershell shell scripts can compiled and obfuscated, then they will see it as some form of IPR protection upto some extent

Hi @zaxebo1 a few quick thoughts!

  • Have you considered script signing, if your concern is modification of scripts?
  • Have you considered hiring, or training your team(s) to use a core tool that anyone (IMHO) in a Microsoft ecosystem should be familiar with?

No offense intended, just offering some alternatives that might work, given that this seems a (IMHO) very low priority.

Cheers!

Hello @zaxebo1,

I tend to agree with @RamblingCookieMonster , while I understand the challenges you have, I also see the threat of suddenly getting bad code put into compiled executables that will be more difficult to troubleshoot. In addition I feel that other people should be able to see the code, as it provides an excellent way for others to learn. Last but not least, believe me, I've been there back in the 90s when we used the WinBatch compiler all over the place, so much compiled executables, bad managed source code repositories, and there you go, the guy that wrote the executable no longer works for the company and you won't have access to the source anymore.

Just my 2 cents.
Alex

I was able to learn so much about how PowerShell works simply by reading other scripts/modules after using them. I'd hate to see the source code hidden inside of a .EXE when it seems like code signing and execution policies fit this scenario.

I remember the days of DOS and Clipper. It was great to be able to compile essentially scripts and run them directly. But in the modern world any "unknown" executables is a significant problem. Moreover modern OS is able to run scripts directly and security problem is solved by script signing. This gives admins and users the best experience.
... although the idea is beautiful at all times :blush:

Was this page helpful?
0 / 5 - 0 ratings