Chr*_*ris 5 powershell iis-7.5
目标:使用PowerShell更新IIS7.5站点的现有主机头
问题:Set-WebBinding需要我没有的网站名称.我确实有HostHeader.
场景:我在IIS中有多个站点.其中一些有一个主机头,其中包含我想要更改的特定字符串.
Site1 - site1.stuff.domain.net
Site2 - site2.stuff.domain.net
Site3 - site3.domain.net
Run Code Online (Sandbox Code Playgroud)
我想更改.stuff标题中包含的所有网站.
我正在使用Get-WebBinding获取所有网站及其绑定的列表.然后我循环遍历它们并检查是否bindingInformation包含.stuff.我修改字符串我喜欢然后去更新标题
Set-WebBinding -HostHeader $originalHeader -SetProperty HostHeader -Value $newHeader
Run Code Online (Sandbox Code Playgroud)
显然,您必须拥有该网站的名称才能使用Set-WebBinding,不同的Get-WebBinding是,您可以根据HostHeader(Get-WebBinding -HostHeader $someValue)获取绑定.有没有一种方法可以Set-WebBinding在Name不指定网站的情况下使用?有没有办法从网站上获取该网站的名称Get-WebBinding?有替代品Set-WebBinding吗?或者有更好的方法来做我想做的事情吗?
尝试一下:
Get-WebBinding -HostHeader *.stuff.* | Foreach-Object{
#$NewHeader = $_.bindingInformation -replace '\.stuff\.','.staff.'
Set-WebConfigurationProperty -Filter $_.ItemXPath -PSPath IIS:\ -Name Bindings -Value @{protocol='http';bindingInformation=$NewHeader}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4135 次 |
| 最近记录: |