2017-07-03 627 views
0

我正在努力自動添加從Cert:\CurrentUser\My創建的證書到Cert:\CurrentUser\TrustedPublisher,以便我可以使用AllSigned ExecutionPolicy。當我使用Import-PfxCertificate cmdlet的(出口,顯然後),我得到Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))導入證書 - 訪問被拒絕(當以管理員身份運行時)

關於這一切的奇怪的事情,我可以進入證書MMC並導入證書自己,但我在嘗試通過運行PowerShell(作爲管理員),它給我的錯誤。

回答

0

我發現我能夠將證書導入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 
相關問題