Load "BLOG", 8, 1

This is the best I could do on short notice.
posts - 11 , comments - 3 , trackbacks - 10

How do I recycle an IIS App pool with Powershell?

Reference implementation of a Powershell script to recycle app pools, in response to Rick's post:
http://www.west-wind.com/weblog/posts/2012/Oct/02/A-tiny-Utility-to-recycle-an-IIS-Application-Pool

Alternatives:

Windows 2003 & II6
C:\WINDOWS\system32>cscript.exe iisapp.vbs /a AppPoolName /r


Windows 2008 IIS7

C:\WINDOWS\system32\inetsrv\appcmd recycle apppool "MyAppPool"
Restart-WebAppPool cmdlet

#    File: RecycleAppPool.ps1
#    Author: Ralph Willgoss
#    Date: 2nd Oct 2012

#    Reference:
#    http://stackoverflow.com/questions/198623/how-do-i-recycle-an-iis-apppool-with-powershell
# =============================================================================
#    Iniatialise
=============================================================================
param ( )

=============================================================================
#   Main
=============================================================================

Write-OutPut ""
Write-OutPut "Starting Recycling App Pool"
Write-OutPut ""

$appPoolName = "AppPoolName" #$args[0]
$appPool = Get-WmiObject -namespace "root\MicrosoftIISv2" -class "IIsApplicationPool"
          | Where-Object { $_.Name -eq "W3SVC/APPPOOLS/$appPoolName" }
          
$appPool.Recycle()

Write-OutPut ""
Write-OutPut "Finished Recycling App Pool"
Write-OutPut ""

Print | posted on Sunday, November 25, 2012 10:36 AM | Filed Under [ Powershell ]

Feedback

Gravatar

# re: How do I recycle an IIS App pool with Powershell?

You can achieve this even more easily (2 lines!) using the WebAdministration module. It ships with Windows 7/Server 2008 R2, and works for IIS 7.0 and above; it's downloadable for Windows Vista/Server 2008. Mike Chaliy's comment on Rick Strahl's original post documents it in full: http://www.west-wind.com/weblog/posts/2012/Oct/02/A-tiny-Utility-to-recycle-an-IIS-Application-Pool#1474659
11/25/2012 5:17 PM | Alastair Smith
Gravatar

# re: How do I recycle an IIS App pool with Powershell?

Thanks Alastair, updated!
12/2/2012 1:49 PM | Ralph Willgoss
Post A Comment
Title:
Name:
Email:
Comment:
Verification:
 
 

Powered by: