从powershell创建自签名的iis ssl证书

Rob*_*ton 9 iis powershell ssl iis-7 ssl-certificate

我需要从PowerShell脚本创建一个新的自签名IIS SSL证书,作为自动安装的一部分.

这是我尝试过的:

Import-Module WebAdministation

New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https

New-SelfSignedCertificate -Subject Fluency -DnsName $computerName.$domainName -CertStoreLocation cert:\LocalMachine\My

Get-ChildItem cert:\LocalMachine\My | where { $_.Subject -match "CN\=$Computername\.$DomainName" } | select -First 1 | New-Item IIS:\SslBindings\0.0.0.0!443
Run Code Online (Sandbox Code Playgroud)

结果

它表示无法找到该行的New-SelfSignedCertificate.如果我通过IIS管理器手动创建证书,其余代码工作正常.

谢谢你的帮助!

Avn*_*ner 13

我让它以这种方式工作

    Import-Module WebAdministration

    Set-Location IIS:\SslBindings

    New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https

    $c = New-SelfSignedCertificate -DnsName "myexample.com" -CertStoreLocation cert:\LocalMachine\My

    $c | New-Item 0.0.0.0!443
Run Code Online (Sandbox Code Playgroud)