【问题标题】:How to install a Certificates using powershell script如何使用 powershell 脚本安装证书
【发布时间】:2016-04-12 18:40:52
【问题描述】:

我正在尝试通过 PowerShell 脚本安装证书。按照 Microsoft PowerShell 文档中的建议,我正在使用 Import-Certificate 方法。

这是我的代码:

$script = {
    $file = ( Get-ChildItem -Path  C:\Users\Administrator\Desktop\newCert.cer )
    $file | Import-Certificate -CertStoreLocation cert:\CurrentUser\Root
    echo $file
    }

invoke-command -Credential $clientCred -ComputerName $ClientIP -ScriptBlock $script

我收到以下错误:

UI is not allowed in this operation
    + CategoryInfo          : InvalidArgument: (:) [Import-Certificate], ArgumentException 

我不确定这是哪里出了问题 - 如果有人能指出我正确的方向,那将非常有帮助。

【问题讨论】:

    标签: powershell ssl ssl-certificate


    【解决方案1】:

    这里的问题是,当您将证书安装到Cert:\CurrentUser\Root(当前用户帐户中的受信任的根 CA)时,底层 CryptoAPI 会调用以下对话框:

    这就是错误消息提到 UI 的原因。由于您试图在远程会话中安装证书,因此无法在远程主机的交互式会话中按下按钮。这就是 UI 对话框被禁止的原因。

    您可以做的是将证书安装到本地计算机存储。即安装到Cert:\LocalMachine\Root

    请注意,将根证书安装到本地机器存储时,它会自动传播到该机器上的所有用户帐户。也就是说,可以为可能不应该信任的用户建立无意的信任。

    【讨论】:

    • 注意 - 这需要在提升的会话中以避免访问被拒绝错误
    猜你喜欢
    • 2018-08-08
    • 2011-01-24
    • 1970-01-01
    • 2022-10-17
    • 2018-01-27
    • 1970-01-01
    • 1970-01-01
    • 2014-02-12
    • 1970-01-01
    相关资源
    最近更新 更多