powershell - New-SelfSignedCertificate -CertStoreLocation 找不到路径

标签 powershell certificate

使用 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

关于powershell - New-SelfSignedCertificate -CertStoreLocation 找不到路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44763022/

相关文章:

azure - 如何验证 Azure 虚拟机 RDP 证书?

c# - 服务结构: Authenticating with Azure KeyVault via cert: "KeySet does not exist"

powershell - Exchange Remote Powershell 出现零星 'Broken' 状态

perl - 在Windows中使用dos批处理程序的原因是什么?

powershell - 如何使用 powershell 配置 Windows 与已知 IP 持续同步时间

powershell - 组合多个逻辑运算符

google-chrome - 当你使用 'badidea' 或 'thisisunsafe' 绕过 Chrome 证书/HSTS 错误时,它只适用于当前站点吗?

openssl - 链式客户端证书

rest - 具有自签名证书的 AFNetwork

.net - 替换整行会产生重复出现的替换文本