Error using appcmd to add ssl binding
Asked Answered
J

6

14

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?

Justle answered 8/3, 2012 at 11:11 Comment(0)
A
11

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
Alidia answered 9/3, 2012 at 0:12 Comment(1)
Where dit you get the syntax without /+ or /- from? Can you provide the link to the documentation please?Villiers
O
17

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

Outandout answered 6/9, 2012 at 14:30 Comment(1)
Thank you! I was getting a headache trying to make this work in PowerShell. :)Croaky
A
11

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
Alidia answered 9/3, 2012 at 0:12 Comment(1)
Where dit you get the syntax without /+ or /- from? Can you provide the link to the documentation please?Villiers
V
0

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"""
Viguerie answered 13/12, 2013 at 18:51 Comment(0)
F
0

You need to run your command as administrator.

Fluid answered 20/7, 2014 at 11:12 Comment(0)
A
0

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.

Austinaustina answered 22/12, 2015 at 22:41 Comment(0)
R
0

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
Recover answered 21/4, 2016 at 18:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.