Stopping IIS websites permanently with PowerShell

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.

Tags:

Iis

Powershell