[英]Create self signed iis ssl certificate from powershell
I need to create a new self-signed IIS SSL certificate from a PowerShell script as part of an automated install. 我需要从PowerShell脚本创建一个新的自签名IIS SSL证书,作为自动安装的一部分。
Here's what I've tried: 这是我尝试过的:
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
Result 结果
It says New-SelfSignedCertificate cannot be found for that line. 它表示无法找到该行的New-SelfSignedCertificate。 If I create the certificate manually through the IIS manager, the rest of the code works fine. 如果我通过IIS管理器手动创建证书,其余代码工作正常。
Thanks for your help! 谢谢你的帮助!
I got it to work this way 我让它以这种方式工作
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.