12.19. Creating Application Pools

Problem

You want to create a new application pool.

Solution

Using a graphical user interface

  1. Open Internet Information Services (IIS) Manager.

  2. In the left pane, expand the server node in the console tree and select Application Pools.

  3. Right-click on Application Pools and select New Application Pool.

  4. Type a descriptive name for the new pool.

  5. Choose whether to use an existing pool as a template (select the existing pool whose configuration settings you want to copy) or leave the configuration settings for the new pool at their default values.

  6. Click OK to create the new pool.

Using VBScript

' This code creates an app pool.
' ------ SCRIPT CONFIGURATION ------
strComputer = "<ServerName>"
strAppPoolName = "<AppPoolName>"
' ------ END CONFIGURATION ---------
   
set objAppPools = GetObject("IIS://" & strComputer & "/w3svc/AppPools")
set objNewAppPool = objAppPools.Create("IIsApplicationPool", strAppPoolName)
   
' Recycle this app pool every 2,000 requests 
objNewAppPool.AppPoolRecycleRequests = True 
objNewAppPool.PeriodicRestartRequests = 2000
   
' Run this app pool as NETWORK SERVICE (just like the default app pool) 
objNewAppPool.AppPoolIdentityType = 2
   
' Save new app pool
objNewAppPool.SetInfo( )
   
WScript.Echo "App Pool created successfully: " & objNewAppPool.Name

Discussion

Application pools are used to assign worker processes for dynamic applications running on IIS. An application pool can have one or more worker processes servicing one or more applications assigned ...

Get Windows Server Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.