Powershell IIS7 管理单元将 SSL 证书分配给 https 绑定 [英] Powershell IIS7 Snap in Assign SSL certificate to https binding

查看:30
本文介绍了Powershell IIS7 管理单元将 SSL 证书分配给 https 绑定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为我们自动化构建过程的一部分,我们正在使用 powershell 脚本破坏和重建我们的 IIS 站点.

As part of our automated build procedure we are trashing and reconstructing our IIS site with powershell scripts.

一旦我创建了 AppPool 和带有绑定信息的网站,我想为 https 绑定设置 SSL 证书.我在网上找不到任何具体的例子来证明这一点.

Once i have created the AppPool and the website complete with binding information I want to set the SSL certificate for the https binding. I can't find any concrete examples onl;ine anywhere that demonstrate this.

有什么想法吗?

寻找一个仁慈的powershell神...

Looking for a benevolent powershell god...

推荐答案

以下是简单的方法:

首先确定您要分配的证书并获取其指纹

First identify thecertificate that you want to assign and obtain it's thumbprint

例如您的证书可能位于 cert:LocalMachineRoot

e.g. Your certificate might be in cert:LocalMachineRoot

您可以通过以下方式获取指纹:

You can obtain the thumbprint with the following:

$thumb = (Get-ChildItem cert:LocalMachineRoot | where-object { $_.Subject -like "YOUR STRING HERE*" } | Select-Object -First 1).Thumbprint

<<<现在可以将证书分配给一个 ip 地址和端口 comme ci >>>

<<< Now one can assign the certificate to an ip address and port comme ci >>>

$IPAddress = 101.100.1.90

$port = 443

Push-Location IIS:SslBindings

Get-Item cert:LocalMachineRoot$thumb | New-Item $IPAddress!$port

Pop-Location

希望对大家有帮助

这篇关于Powershell IIS7 管理单元将 SSL 证书分配给 https 绑定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆