将 PowerShell 脚本转换为 exe

Convert PowerShell script to exe

我希望将 PS1 文件转换为 .exe 文件,以便我可以将其推广给技术水平较低的用户。

我相信,如果他们只需要双击它,而不是解释如何通过 PowerShell 运行,对他们来说会容易得多。

我怎样才能做到这一点?

使用 PS2EXE 而不是此在线工具,如果您的脚本中包含机密信息,它会强制您上传脚本并造成安全漏洞。

有可用的GUI模式;要了解更多信息,请参阅 the GitHub repository

您有一些付费和不付费的解决方案。我同意最后的回答,不要使用在线工具,除非你确定他们没有保留你的代码并且你信任他们。

想到了两个免费的:

PS2EXE-GUI

PS1 To EXE by F2KO(确保它是本地安装命令行界面,而不是网络界面)

付费的是:

PowerShell Studio

ISE Steroids 2.0 Enterprise

注意:我认为免费的应该适合大多数用途。不过我确实喜欢 PowerShell Studio。

PS2EXE 工具更新(所有版本均为 open-source):

原剧本来自Ingo Karstein,但2017年好像停止开发了,大家可以找他的blog here, and his contribution on Microsoft Technet's forums here.

Markus Scholtes 继续开发脚本,添加了一些有用的功能。您可以在 Microsoft Technet here, and github repository here.

上找到他的 post

Powershelling 的回答将您指向 Stuart Dootson (here and here) 的 Markus 项目的一个分支,该分支较少维护。明显的区别是“添加了对需要提升的脚本的支持。这会在该工具生成的可执行文件中插入一个合适的清单。用他的脚本版本构建的 .exe 文件需要提升".

我建议查看 Markus Scholtes 的版本,但要注意 (!)(README.md 2020 年 11 月 3 日):

Attention: Incorrect virus detection of PS2EXE

Some stupid idiot seems to have abused PS2EXE to compile his computer virus script. As a result, a rapidly growing number of virus scanners recognize programs created with PS2EXE as malicious programs and delete them.

There is only one hope to save the PS2EXE project: Please send your (harmless) programs created with PS2EXE via the web forms from the virus scanners' vendors for reporting false positives (I've already done it with some of them, please use only the false positive page)!

If this is not successful, then I will have to quit PS2EXE as nobody can use it anymore.

Thank you for your support