Recycle Application Pool using Powershell Script Recycle Application Pool using Powershell Script powershell powershell

Recycle Application Pool using Powershell Script


I like when answers are short and simple, like this...

Restart-WebAppPool (Get-Website -Name <YourSiteName>).applicationPool


You can use appcmd.exe:

appcmd recycle apppool /apppool.name:'MyAppPool'

You can also retrieve the corresponding WMI instance and invoke the Recycle() method:

$myAppPool = Get-WmiObject -Namespace root\WebAdministration -Class ApplicationPool -Filter "Name = 'MyAppPool'"$myAppPool.Recycle()


Import-Module WebAdministration$site = "MySite"$pool = (Get-Item "IIS:\Sites\$site"| Select-Object applicationPool).applicationPool#Recycle the application pool:Restart-WebAppPool $pool