代码之家  ›  专栏  ›  技术社区  ›  Amruta

导出Pfxcertificate命令在Powershell中不可用

  •  0
  • Amruta  · 技术社区  · 6 年前

    .cer .pfx 使用powershell的文件。

    $certroot = "C:\Script\Certificate"
    $certname = "TestCertificate15"
    $password = read-host "Enter certificate password" -AsSecureString
    $startdate = Get-Date
    $enddate = $startdate.AddYears(2)
    C:\Script\Certificate\makecert.exe -r -pe -n "CN=$certname" -b ($startdate.ToString("MM/dd/yyyy")) -e ($enddate.ToString("MM/dd/yyyy")) -ss my -len 2048
    $cert = Get-ChildItem Cert:\CurrentUser\My | ? {$_.Subject -eq "CN=$certname"}
    Export-Certificate -Type CERT -FilePath "$certroot\$certname.cer" -Cert $cert -Force
    Export-PfxCertificate -FilePath "$certroot\$certname.pfx" -Cert $cert -Password $password -Force
    

    我还将windows powershell框架版本升级到5.1。

    谢谢您。

    0 回复  |  直到 6 年前