【问题标题】:New-SelfSignedCertificate to create certificate gives Access DeniedNew-SelfSignedCertificate 创建证书给出拒绝访问
【发布时间】:2018-01-19 02:03:53
【问题描述】:

我正在尝试在 PowerShell 中使用 New-SelfSignedCertificate 在 Windows 10 上创建证书,但该命令给了我权限错误。我使用的是管理员帐户。

命令:

New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, O=Contoso Corporation, C=US" -KeyUsage DigitalSignature -FriendlyName MyCert -CertStoreLocation "Cert:\LocalMachine\My"

输出:

New-SelfSignedCertificate : CertEnroll::CX509Enrollment::_CreateRequest: Access denied. 0x80090010 (-2146893808 NTE_PERM)
At line:1 char:1
+ New-SelfSignedCertificate -Type Custom -Subject "CN=Contoso Software, ..."
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-SelfSignedCertificate], Exception
    + FullyQualifiedErrorId : System.Exception,Microsoft.CertificateServices.Commands.NewSelfSignedCertificateCommand

【问题讨论】:

  • 您能否访问“Cert:\LocalMachine\My”位置,即查看Get-item "Cert:\LocalMachine\My"的输出
  • 看起来像。没有错误,但输出只是Name: My
  • New-SelfSignedCertificate 是你自己写的吗?
  • @TheIncorrigible1 New-SelfSignedCertificate 是一个内置 cmdlet...
  • 这意味着窗口没有升高。这意味着该窗口没有管理员权限。启动 PowerShell 时,右键单击以管理员身份运行。或者在未升高的窗口中,Start-Process powershell.exe -Verb Runas

标签: windows powershell certificate


【解决方案1】:

不是正确的答案。运行权限是问题所在。

【讨论】:

    【解决方案2】:

    通过指定不同的证书位置为您的本地用户帐户创建证书:

    New-SelfSignedCertificate -CertStoreLocation "Cert:\CurrentUser\My" [...]
    

    【讨论】:

      【解决方案3】:

      如 cmets 中所述,尽管 PowerShell.exe 在具有“管理权限”的用户帐户下运行。除非被提升,否则该进程无法使用这些权限。

      PowerShell 窗口默认会在标题栏中添加“管理员:”。否则,您可以通过运行以下命令来检查您是否是管理员:

      ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole‌​([Security.Principal‌​.WindowsBuiltInRole] "Administrator")
      

      当您通过 GUI 启动 PowerShell 时,您可以右键单击 -> 以管理员身份运行。

      否则,您可以生成一个通过运行Start-Process powershell.exe -Verb Runas 提升的新进程

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-10-10
        • 2013-09-09
        • 2013-11-11
        • 1970-01-01
        • 2018-01-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多