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

 石头1988030450 发布于 2023-01-29 10:42

我需要从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

结果

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

谢谢你的帮助!

1 个回答
  • 我让它以这种方式工作

        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
    

    2023-01-29 10:45 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有