简体   繁体   English

使用 Powershell 从 WebBinding 时如何获取网站名称?

[英]How do I get the website name when from a WebBinding using Powershell?

So I'm writing a Powershell script to validate all HTTPS bindings of all websites actually have a respective SSL binding.所以我正在编写一个 Powershell 脚本来验证所有网站的所有 HTTPS 绑定实际上都具有各自的 SSL 绑定。 I know this sounds pointless, becasue the IIS Management interface already validates this when trying to save such a binding, but trust me when I say this isn't always the case when you have a mix of bindings in a shared IIS configuration, where some bindings use certificates from the CCS and some use locally installed certificates.我知道这听起来毫无意义,因为 IIS 管理界面在尝试保存此类绑定时已经对此进行了验证,但是请相信我,当您在共享 IIS 配置中混合绑定时,请相信我说情况并非总是如此,其中一些绑定使用来自 CCS 的证书,有些使用本地安装的证书。

I've already written a script that can provide me with a list of website bindings, that don't have a corresponding SSL binding.我已经编写了一个脚本,可以为我提供网站绑定列表,但没有相应的 SSL 绑定。 This list is compiled using the Get-WebBinding scriptlet.此列表是使用Get-WebBinding scriptlet 编译的。

I'm probably overlooking something very simple, but does anybody know how to determine the website name from just a WebBinding?我可能忽略了一些非常简单的事情,但是有人知道如何仅从 WebBinding 确定网站名称吗?

Never mind, I found a way to do this afterall:没关系,我找到了一种方法来做到这一点:

function GetWebsiteName() {
  param (
    [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] $binding
  )

  $binding.ItemXPath -replace '(?:.*?)name=''([^'']*)(?:.*)', '$1'
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用Get-WebBinding选择没有主机头的绑定 - How to select binding with no host header using Get-WebBinding 从Powershell中的Get-WebBinding获取字符串格式的IIS IP地址 - Get an IIS IP address in string format from Get-WebBinding in Powershell 如何获取 PowerShell 中的本地主机名称? - How do I get the localhost name in PowerShell? 使用Powershell,如何使用从Get-ChildItem获得的对象名称填充变量? - With Powershell, how do I populate a variable with the name of objects I get from Get-ChildItem? 带名称属性的Powershell New-WebBinding管道问题 - Powershell New-WebBinding Pipeline Issue with Name Property Powershell:如何从 Azure Active Directory 用户获取名称 (Get-AzADUser) - Powershell: How do I get the name from Azure Active Directory user (Get-AzADUser) 使用Powershell登录后如何从网站获取表数据? - How do you get table data from a website after you login using powershell? 使用Powershell,如何获得给定服务名称的Azure VIP? - Using Powershell, how do I get the Azure VIP of a given Service Name? 如何使用 powershell 从网站获取链接的价值? - How to get value of a link from a website with powershell? 从 PowerShell 5.1 到 7.2.5 Get-Service -ComputerName 不再存在,那我如何获取计算机名称? - from PowerShell 5.1 to 7.2.5 Get-Service -ComputerName doesn't exist anymore, how do I get computer name then?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM