如何信任Windows Powershell中的证书 [英] How to trust a certificate in Windows Powershell

查看:166
本文介绍了如何信任Windows Powershell中的证书的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Windows 7 ,并希望从 Powershell Powershell的>安全设置设置为全签名 ,并且我的脚本使用有效证书签名来自我的公司。我还已将 .pfx文件添加到我的本地证书存储(右键单击pfx文件并安装)

I am using Windows 7, and want to run signed scripts from Powershell, the security-settings of Powershell are set to "all-signed", and my scripts are signed with a valid certificate from my company. I have also added the .pfx-file to my local certificate store (right-clicked the pfx-file and installed).

但是,当我启动签名脚本时,会收到一条消息,提示:

However, when I start a signed script, I get a message that says:

"Do you want to run software from this untrusted publisher?
File Z:\Powershell Signed Scripts\signed.ps1 is published by CN=[MyCompanyName] and is not trusted on your system. Only run scripts from
 trusted publishers.
[V] Never run  [D] Do not run  [R] Run once  [A] Always run  [?] Help
(default is "D"):"

由于我想在系统上自动调用这些脚本,因此我想将导入的证书添加到系统上的受信任列表中,以便首次运行签名脚本时不再收到任何消息。如何使我的证书成为受信任的证书?

Since I want to automatically call these scripts on my systems, I would like to add my imported certificate to the trusted list on my system, so that I do not get a message anymore when I run a signed script for the first time. How can I make my certificate a trusted one?

推荐答案


如何在Windows Powershell中信任证书

How to trust a certificate in Windows Powershell

实际上,您可以在没有任何mmc的情况下执行此操作:)

Indeed, you can do this without any mmc :)

首先,请检查您的个人证书的位置,例如 Power:

First, check the location of your personal certificate named for example "Power" :

Get-ChildItem -Recurse cert:\CurrentUser\ |where {$_ -Match "Power"} | Select PSParentPath,Subject,Issuer,HasPrivateKey |ft -AutoSize

(此为空:)

gci cert:\CurrentUser\TrustedPublisher

使用证书路径构建命令:

Build the command with the path to your certificate:

$cert = Get-ChildItem    Certificate::CurrentUser\My\ABLALAH

证书存储区在这里,我在两个证书存储上工作:用户和计算机

$store = New-Object 
$store = New-Object System.Security.Cryptography.X509Certificates.X509Store "TrustedPublisher","LocalMachine"
$store.Open("ReadWrite")
$store.Add($cert)
$store.Close()

检查,您应该找到您的证书:

Check, you should find your certificate :

ls cert:\CurrentUser\TrustedPublisher

这篇关于如何信任Windows Powershell中的证书的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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