I had a need recently to stop all the sites running on a Windows server, but I didn’t want to stop IIS. This specific server has hundreds of sites running on it, so stopping each one at a time would have taken an excessive amount of time.
So with a little Google-fu I stumbled across an old post that leverages appcmd
c:\windows\system32\inetsrv\appcmd.exe list site /xml /state:"$=started" | appcmd stop site /in
This single command will pull a list of all the sites that currently have a running state of “started” and then pipe that list into the stop command. This runs super-fast even on a server with hundreds of sites – very impressive and using this saved me tons of time!
Happy IIS hosting! :)
By the way, here’s the inverse of this script to restart all the sites on an IIS server.
Thanks a lot Brad! Nice and useful IIS tip! Keep it up.