Iis – Stopping IIS websites permanently with PowerShell

iispowershell

Stopping websites using Stop-Website is, apparently, not the same as stopping them using the IIS Manager.

Stop-Website 'Some site'
iisreset.exe
# site is started again

Using IIS Manager, the state is the same after a reset/reboot. I guess stopping a site using IIS Manager modifies some sort of persistent configuration (the registry?).

Can anyone tell me how I can use PowerShell to stop a site permanently, so that a reset/reboot does not bring the site online again?

(Stop-WebAppPool exhibits exactly the same behavior.)

Best Answer

Joseph's answer makes perfect sense, but it doesn't seem to work.

The attribute 'serverAutoStart' on the site node in applicationHost.config is not changed.

One way to change is:

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -filter "system.applicationHost/sites/site[@name='Default Web Site']" -name "serverAutoStart" -value "False"

but that's a mouthful.

Another way is:

Set-ItemProperty "IIS:\Sites\Default Web Site" serverAutoStart False

It's also interesting that this attribute is not directly editable in IIS Manager, you have to go into the Configuration Editor to change it.

Yes, starting or stopping the site in IIS Manager changes that attribute, but that's not obvious to the user.