Restart IIS appPool with Powershell
Published on: 16th Dec 2019
Updated on: 26th Jul 2025
Explanation
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"
Related posts
- Get all website entries in IIS using Powershell
- Setting up IIS server with Powershell
- View the binding for the website in IIS with Powershell
Back to #POWERSHELL blog
Back to #blog listing