Powershell Script – Recycle Specific Application Pool
Introduction
The following script will restart application pool of IIS based on user input. User will just select the number which application pool to restart. Very good on demand usage script
Import-Module WebAdministration -ErrorAction SilentlyContinue $pooltable = @{} $pools = gci iis:\apppools $i = 0 Write-Host "Select Application Pool to Restart" Write-Host "" foreach ($a in $pools ) { $pool = $a.Name $i += 1 $pooltable.Add($i, $pool) Write-Host "$i > To restart app pool : $pool " } Write-Host "" $answer = read-host "Enter # of Application Pool to Restart " if ($answer) { foreach ($h in $pooltable.GetEnumerator()) { $key = $h.Name $val = $h.Value if ($key -eq $answer) { Write-Host "Restarting : $val" Restart-WebAppPool $val } } } Write-Host "Complete" -ForegroundColor Magenta Write-Host ""
Save the script into a powershell script file and execute. Script will prompt user which application pool to restart. User can input the desired index number pointing to tha application pool
Conclusion
Hope this powerful script will help you to quickly recycle desired app pool.
March 17, 2015
В·
Adi В·
No Comments
Tags: application pool, Powershell, recycle app pool В· Posted in: Powershell, Sharepoint 2010, SharePoint 2013
Leave a Reply