我需要从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:LocalMachineMy
Get-ChildItem cert:LocalMachineMy | where { $_.Subject -match "CN=$Computername.$DomainName" } | select -First 1 | New-Item IIS:SslBindings .0.0.0!443
结果
它说该行找不到新的符号验证。如果我通过IIS管理器手动创建证书,则其余代码正常。
感谢您的帮助!
我把它这样工作
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:LocalMachineMy
$c | New-Item 0.0.0.0!443