导入证书——以管理员身份运行时访问被拒绝

3
我正在尝试自动将我在“Cert:\CurrentUser\My”中创建的证书添加到“Cert:\CurrentUser\TrustedPublisher”,以便我可以使用AllSigned ExecutionPolicy。当我使用“Import-PfxCertificate” cmdlet(显然是在导出之后),我遇到了“Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))” 的错误。
奇怪的是,虽然我可以进入证书MMC并导入证书,但尝试通过PowerShell(作为管理员)运行此操作时,它会给我报错。
1个回答

1
我发现我可以将证书导入到LocalMachine,但无法导入到CurrentUser。
Import-PfxCertificate -FilePath 'Path\Cert.pfx' -Password (Get-Credential).Password -CertStoreLocation Cert:\LocalMachine\Root
Import-PfxCertificate -FilePath 'Path\Cert.pfx' -Password (Get-Credential).Password -CertStoreLocation Cert:\LocalMachine\TrustedPublisher

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接