PowerShell脚本数字签名错误 [英] PowerShell Script digitally signed error

查看:84
本文介绍了PowerShell脚本数字签名错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行PowerShell脚本时出现错误:

I'm getting an error when I run a PowerShell script:


无法加载文件test_new.ps1。文件test_new.ps1没有经过数字签名。

File test_new.ps1 cannot be loaded. The file test_new.ps1 is not digitally signed.

我创建了一个CA和一个证书,并使用此处

I created a CA and a certificate and signed this file using the procedure described here.

这里是我在 MY 目录中执行 dir 的时候:

Here is when I do a dir on the MY directory:


EF76B3D7D8D2406E1F2EE60CC40644B122267F18  CN=PowerShell User

我可以看到在 test_new.ps1 文件末尾附加的签名块。

I can see the signature block appended at the end of the test_new.ps1 file.

这是执行策略和范围:


        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       AllSigned
   UserPolicy       Undefined
      Process          Bypass
  CurrentUser       AllSigned
 LocalMachine       Undefined

机器策略应优先设置为 AllSigned 的实体。一切似乎都很好,为什么我仍然会收到经过数字签名的错误。

The machinepolicy should take priority which is set as AllSigned. Everything seems allright, why am I still getting the digitally signed error.

推荐答案

最后找到了解决方案:

$cert=Get-ChildItem cert:\CurrentUser\MY
$store = New-Object 
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store ("TrustedPublisher" , "LocalMachine")
$store.Open("ReadWrite")
$store.Add($cert)
$store.Close()

它必须在 TrustedPublisher中发布存储它。

这篇关于PowerShell脚本数字签名错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆