New-SelfSignedCertificate -CertStoreLocation 找不到路径
New-SelfSignedCertificate -CertStoreLocation cannot find path
使用 New-SelfSignedCertificate cmdlet,我想将硬盘上的位置指定为 C:\Development\My Project。这个命令:
New-SelfSignedCertificate -CertStoreLocation "cert:\LocalMachine\Development\My Project"
出现此错误:
Cannot find path 'Cert:\LocalMachine\Development\My Project' because
it does not exist.
我该怎么做?
$PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 962
您为 New-SelfSignedCertificate -CertStoreLocation
指定的路径是证书存储区,而不是文件路径。您最有可能想要做的是指定 cert:\LocalMachine\my
,这将在您的个人存储中创建证书,然后如果您需要以文件形式将该证书导出到硬盘驱动器上的文件中。像这样的东西应该适用于:
$notAfter = [datetime]::Today.AddYears(2)
$thumb = (New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName $env:USERDNSDOMAIN -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $notAfter).Thumbprint
$pwd = 'SuperS3cret!'
$SSpwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
Export-PfxCertificate -cert "cert:\localmachine\my$thumb" -FilePath "C:\Development\My Project\MyDevCert.pfx" -Password $SSpwd
当我对 CurrentUser 范围有一个未定义的执行策略时,我得到了这个错误。
Get-ExecutionPolicy -List
如果未定义,请使用此命令将其设置为 RemoteSigned
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
使用 New-SelfSignedCertificate cmdlet,我想将硬盘上的位置指定为 C:\Development\My Project。这个命令:
New-SelfSignedCertificate -CertStoreLocation "cert:\LocalMachine\Development\My Project"
出现此错误:
Cannot find path 'Cert:\LocalMachine\Development\My Project' because it does not exist.
我该怎么做?
$PSVersionTable.PSVersion Major Minor Build Revision ----- ----- ----- -------- 5 0 10586 962
您为 New-SelfSignedCertificate -CertStoreLocation
指定的路径是证书存储区,而不是文件路径。您最有可能想要做的是指定 cert:\LocalMachine\my
,这将在您的个人存储中创建证书,然后如果您需要以文件形式将该证书导出到硬盘驱动器上的文件中。像这样的东西应该适用于:
$notAfter = [datetime]::Today.AddYears(2)
$thumb = (New-SelfSignedCertificate -CertStoreLocation cert:\localmachine\my -DnsName $env:USERDNSDOMAIN -KeyExportPolicy Exportable -Provider "Microsoft Enhanced RSA and AES Cryptographic Provider" -NotAfter $notAfter).Thumbprint
$pwd = 'SuperS3cret!'
$SSpwd = ConvertTo-SecureString -String $pwd -Force -AsPlainText
Export-PfxCertificate -cert "cert:\localmachine\my$thumb" -FilePath "C:\Development\My Project\MyDevCert.pfx" -Password $SSpwd
当我对 CurrentUser 范围有一个未定义的执行策略时,我得到了这个错误。
Get-ExecutionPolicy -List
如果未定义,请使用此命令将其设置为 RemoteSigned
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser