开发者

Powershell 2 remove single binding iis 7

I am trying to remove one site binding. I am using powershell 2 and iis 7. I am able to remove all bindings with Remove-ItemProperty, and when i use Set-ItemProperty it removes all binding and just adds the new. I would be great if i 开发者_JAVA百科could just rename or just remove a single binding without effecting the others. A sample would be great.


You shouldn't be using the itemproperty cmdltes (you could, but it's trickier.) There are dedicated cmdlets for this in the WebAdministration module. See:

help remove-webbinding -examples

-Oisin


I think xOn is correct that you should be using the higher level cmdlets but these commands based on the *-ItemProperty cmdlets allow you to modify an existing binding. I'm not sure of the syntax to remove one of the bindings though.

$bindings = (Get-ItemProperty -Path 'IIS:\Sites\Default Web Site' -Name Bindings)
$bindings.Collection[0].bindingInformation = '*:80:'
Set-ItemProperty -Path 'IIS:\Sites\Default Web Site' -Name Bindings -Value $bindings

Read the PowerShell Snap-in: Making Simple Configuration Changes to Web-Sites and Application Pools article to see how to work with the *-ItemProperty commands properly. There is a whole series of articles on Using Scripts to Automate Management to manage IIS 7

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜