I am not clear about your scenario but I guess, you are trying to remove a certain binding but if the target site has only that binding you want to get exception instead of removing the binding. Am I right? If so, I think you can use this script code for that purpose.
if ($null -ne (Get-WebBinding -name "Default Web Site" -port 80 -HostHeader www.site.com -IPAddress 127.0.0.1))
{
if ((Get-WebBinding -name "Default Web Site").count -gt 1) {
Remove-WebBinding -name "Default Web Site" -port 80 -HostHeader www.site.com -IPAddress 127.0.0.1
}
else
{
throw "There is only one binding left for this site"
}
}
else
{
throw "This site does not have the binding"
}
FYI, the parameter "Site" was renamed to "Name" in the latest build. So I used "Name" parameter instead of "Site".