IIS - How to stop a site by Id using appcmd

The basic syntax for this command is: appcmd stop site "Site Name"

But you can stop a site by id, by piping the output of 'appcmd list site' into the input of 'appcmd stop site' using /xml on the former and /in on the latter.

I.e. appcmd list site -id:N /xml | appcmd stop site /in

Open a command prompt using Run as Administrator.

Start site by Id:

C:\Windows\System32\inetsrv>appcmd list site -id:1 /xml | appcmd start site /in
 
"Default Web Site" successfully started.

Stop site by Id:

C:\Windows\System32\inetsrv>appcmd list site -id:1 /xml | appcmd stop site /in
 
"Default Web Site" successfully stopped.

About the /in parameter:

/in or -
Read and operate on XML input from standard input. Use this to operate on input produced by another command running in /xml mode.

Ads by Google


Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath