Welcome to ciysys blog

Restart IIS appPool

Published on: 16th Dec 2019

Updated on: 16th Jan 2022


During the development of new web apps, we often perform testing with different system setup (where the values are stored in the database). And we have many web apps that run on it's own appPool. Restarting the appPool manually through the user interface takes quite a lot of clicks.

To avoid the cumbersome steps to restart all the necessary appPool, we came out with a script (shown below). It's convenient and never misses out any of the appPool that cripples the test case.

Import-Module WebAdministration

cd IIS:\AppPools

$l = Get-ChildItem | where name -Like '*myApps*' | select name

foreach ($a in $l) {
    Write-Host "Restart appPool $($a.name).."
    Restart-WebAppPool $($a.name)

Write-Host "Done" 

Jump to #POWERSHELL blog


Lau Hon Wan, software developer.