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 could just rename or just remove a single binding without effecting the others. A sample would be great.
A:
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
x0n
2010-06-06 17:33:17
A:
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
Martin Hollingsworth
2010-06-09 23:12:01