Quantcast
Channel: Configuration & Scripting
Viewing all articles
Browse latest Browse all 780

IIS - Delete a web binding with BindingInformation that has brackets

$
0
0

Hello, been pulling my hair out on this one and I can't seem to find a way to do this through PS or just using netsh.  Basically I am able to read the bindings on the site and get the objects.  I used the remove-webbinding cmdlet and it says it can't find it to delete it.  But it can if its a valid IP address or lets say it starts with *.  If it is a variable that is [sdfdf:sdfdf:2323:dff] it can't find it period.  Which is odd as I can throw in detection for it and it finds the value with Get cmdlets.  In my dropdown on the site in IIS the value would be site at [2002:a571:9a0b::a571:9a0b].  For some reason I can't remove, hoping people can assist, unless its a bug.  Thanks again for reading this.Foreach ($Site in get-website) {
    Foreach ($Bind in $Site.bindings.collection) {
        ForEach ($F in $Bind.BindingInformation) {
            if ($F.StartsWith("[")) {
                Remove-WebBinding -Name $Site.name -Protocol $Bind.Protocol -BindingInformation $Bind.BindingInformation
                }
            }
        }
    }

Error I get:

Remove-WebBinding : Cannot find binding '[2002:a571:9a0b::a571:9a0b]:80:test.website.com'.
At line:13 char:17
+                 Remove-WebBinding -Name $Site.name -Protocol $Bind.Protocol -Bin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Remove-WebBinding], ArgumentException
    + FullyQualifiedErrorId : InvalidParameter,Microsoft.IIs.PowerShell.Provider.RemoveWebBindingCommand


Viewing all articles
Browse latest Browse all 780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>