APPCMD, how to check if a binding exists before I add it to the site?

We use appcmd in our deployment scripts to configure the servers, I need to make sure that adding bindings to existing sites does not cause an error

C:\Windows\System32\inetsrv\appcmd.exe set site /site.name:"abc.com" /+bindings. [protocol='http',bindingInformation='*:80:alias-abc.com'] 

works, but in the next script run I get an error.

cannot add a duplicate collection record of type "binding" with the combined protocol of attribute keys, bindingInformation ', respectively, http, *: alias-abc.com'

Is there a way to check if a binding exists before adding it to appcmd

(powershell is not allowed - this should be either appcmd or another exe command line)

thanks

+5
source share
1 answer

appcmd is a bit out of the search department, but something like this should work:

 C:\Windows\system32\inetsrv\appcmd.exe list site "abc.com" | findstr bindings:http/*:80 
0
source

Source: https://habr.com/ru/post/1204893/


All Articles