Question

I want to add a binding to a site using appcmd. But when I try the following command I get an error:

appcmd set site /site.name:"My site name" /+bindings.[protocol='https',bindingInformation='*:443:sub.mydomain.com'] 

The error:

ERROR ( message:Cannot find SITE object with identifier "bindingInformation='*:443:sub.mydomain.com']". )

I checked if the site exists and it does. What am I doing wrong?

Was it helpful?

Solution

Try this:

appcmd set site "My site name" /bindings:"https://sub.mydomain.com:443"

But your command is correct as well. List all websites and make sure you are using one of them:

appcmd list site

OTHER TIPS

If you're using PowerShell, you have to surround the bindings parameter with double quotes so that PowerShell doesn't interpret the single quotes before the command is sent to appcmd.

./appcmd set site /site.name: contoso /+"bindings.[protocol='https',bindingInformation='*:443:']"

source: http://technet.microsoft.com/en-us/library/cc731692(v=ws.10).aspx

I ran into a problem in Powershell with the colons in the bindings. Concatenating them solved the issue.

[string] $cmd = "$Env:windir\SysWOW64\inetsrv\APPCMD.exe"
$response = invoke-expression "$cmd add site /name:""$SiteName"" /id:$ID /+""bindings.[protocol='$Protocol',bindingInformation='$IP"+":$Port"+":']"" /physicalPath:""$Path"""

You need to run your command as administrator.

I was never able to make this work with a wildcard certificate for *.mydomain.com with what I thought to be a quite friendly name: "mydomain.com plus wildcard". I'd run the commands above, go into IIS and look at the bindings and it would be there but without a certificate selected. Selecting the certificate would removed the host name and disable it so I couldn't change it.

I finally got it to work by changing the wildcard certificate's friendly name to the format expected by IIS ("*.mydomain.com") and adding it normally through the IIS interface, no idea if the above appcmd commands would work. The moral of this story is to give wildcard certs the standard form friendly name.

I created a batch file to achieve that:

@echo off

set /p sitename="Enter the site Name (as displayed in IIS): " %=%
set /p siteurl="Enter the site Host Header(the site url): " %=%
set /p siteip="Enter the site IP Address (ip address or *): " %=%
set /p siteprotocol="Enter the site Protocol (http, https, etc): " %=%
set /p siteport="Enter the site Port (80, 443): " %=%

appcmd set site /site.name:"%sitename%" /+bindings.[protocol='%siteprotocol%',bindingInformation='%siteip%:%siteport%:%siteurl%']

pause
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top