如何在Windows上获得一个签名的PowerShell脚本没有弃用makecert.exe?

我已经按照这里的说明在Windows上创build代码签名证书来签署PowerShell脚本

但它不工作,因为我得到这个错误:

File C:\temp\script.ps1 cannot be loaded. A certificate chain processed, but terminated in a root certificate which is not trusted by the trust provider. 

我试图只是将创build的证书复制到我的用户和机器信任的发布者,没有运气。

Google给了我: https : //4sysops.com/archives/sign-your-powershell-scripts-to-increase-security/

等等,但他们都需要安装Windows 10 SDK。

我只是试图在我的Server 2016 WSUS服务器上运行https://community.spiceworks.com/scripts/show/2998-adamj-clean-wsus?page=51而不会污染它,但是我可以“将需要PowerShell脚本的组策略更改为AllSigned。

帮帮我?

代码签名实际上只是为了阻止运行恶意的不受信任的脚本的最终用户,它并不是真的打算阻止pipe理员运行他们检查和信任的东西。 因此,可以轻松绕过您有意运行的脚本的限制,而不会永久更改服务器上的默认设置。 这可以通过从batch file或计划任务调用它来完成,如下所示:

powershell.exe -windowstyle hidden -noprofile -executionpolicy bypass -file "C:\powershell script.ps1"