0

Is there a way to recycle all app pools on an IIS6 server at once without using iisreset or manually recycling each one?

Calvin Fisher
  • 111
  • 1
  • 5

3 Answers3

2

If you have the names of all the application pools, you could use iisapp.vbs (in systemroot\system32) in a script to restart them all.

iisapp /a NameOfAppPool /r
pk.
  • 6,451
  • 2
  • 42
  • 63
1

I ended up using the following VBScript for IIS6:

Set oWMI = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}!root\MicrosoftIISv2")
Set aAppPools = oWMI.ExecQuery("Select * from IIsApplicationPool")

For Each oItem in aAppPools
    WScript.Echo("Recycling " & oItem.Name & "...")
    oAppPool.Recycle
Next

WScript.Echo("Recycled " & aAppPools.Count & " Application Pools.")

It has the advantage of not needing to know the names of the application pools beforehand, but you do have to have WMI enabled.

And the version for IIS7:

Set oWebAdmin = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}!root\WebAdministration")
Set aAppPools = oWebAdmin.InstancesOf("ApplicationPool")

For Each oAppPool in aAppPools
    WScript.Echo("Recycling " & oAppPool.Name & "...")
    oAppPool.Recycle
Next

WScript.Echo("Recycled " & aAppPools.Count & " Application Pools.")

Resources:
http://blogs.iis.net/chrisad/archive/2006/08/30/Recycling-Application-Pools-using-WMI-in-IIS-6.0.aspx
http://www.vbsedit.com/scripts/iis/iis6/apps/scr_476.asp
http://msdn.microsoft.com/en-us/library/ms525309(v=vs.90).aspx
http://learn.iis.net/page.aspx/162/managing-sites-with-iis39s-wmi-provider/

Calvin Fisher
  • 111
  • 1
  • 5
0

If you need to recycle them all, you might as well IISReset.

Alternatively (if this is, for example, an FTP preservation exercise), you could try restarting just the WWW Publishing service.

TristanK
  • 9,073
  • 2
  • 28
  • 39