Sysadmins of the North
Share now!





Start all stopped application pools that have Autostart set to true

Just a quicky: Start all stopped application pools in IIS that have the autostart property set to true. Easily with appcmd or the IISAppPool cmdlet that’s available in the IISAdministration PowerShell module. And here is how.

AppCmd supports the piping of commands. You can use the /xml parameter to generate XML formatted output, and pipe it through to the /in parameter. It reads and operates on the XML input.

This makes it ideal to pipe multiple Appcmd commands into a single command, for example to start all application pools that are in a stopped state but having the Autostart property.

appcmd list apppools /state:stopped /autostart:true /xml | appcmd start apppool /in

Here is an example for using Start-WebAppPool with Get-ChildItem to start all application pools with state “Stopped” (WebAdministration PowerShell module):

# if required: Import-Module WebAdministration
Get-ChildItem IIS:\AppPools | Where-Object { $_.autoStart -eq "True" -and $_.state -eq "Stopped" } | Start-WebAppPool

And using IISAdministration module:

Get-IISAppPool | ? { ($_.State -eq "Stopped") -And ($_.AutoStart -eq "False") } | %{ $_.Start() }

Start and recycle application pools using PowerShell Remoting

You can use Invoke-Command -ComputerName to start a session on a remote IIS web server, and use a ScriptBlock to start – or recycle for that matter – application pools:

Invoke-Command -ComputerName webServer -ScriptBlock {
	Get-IISAppPool | ? {
		($_.State -eq "Stopped") -And ($_.AutoStart -eq "False")
	} | %{ $_.Start() }
}

buy me a coffee
Buy Me A Coffee

About the Author Jan Reilink

My name is Jan. I am not a hacker, coder, developer, programmer or guru. I am merely a system administrator, doing my daily thing at Vevida in the Netherlands. With over 15 years of experience, my specialties include Windows Server, IIS, Linux (CentOS, Debian), security, PHP, WordPress, websites & optimization. Want to support me and donate? Use this link: https://paypal.me/jreilink.

follow me on:


Thank you!

Leave a Comment:

Skip to content