I am in the midst of co-authoring a SharePoint administration via PowerShell book with Gary Lapointe.

Automating Microsoft SharePoint 2010 Administration with Windows PowerShell 2.0

ISBN 978-0-470-93920-8

While researching application pools in SharePoint, I discovered some interesting information that I would like to share. When I discovered these, I searched for documentation on-line and could not find anything to support my findings. I then reached out to Spence Harbar who was instrumental in helping to remove the confusion I had around this topic.

SharePoint 2010 has introduced two new “types” of application pools, but before we dive into what these types are, let’s introduce what application pools are and why they are important.

Types of Application Pools

With the release of SharePoint 2010, Microsoft has released two distinct types of application pools. The first is used to host content web applications. The second is used to host service application endpoints. Before we examine these two types, let’s look at the IIS Web Application Pool.

IIS Web Application Pools

Application Pools in IIS 7 can run in one of two modes: integrated mode and classic mode. The web server will process the request differently based on the selected mode. In integrated mode, IIS will use the new request-processing pipelines of IIS and ASP.NET. If classic mode is selected, the server will route requests the same way it did in IIS 6.0; through Aspnet_isapi. For more information on this, check out Managing Application Pools in IIS 7.0.

You can create a new application pool by using the WebAdministration module. This method is very similar to how Central Administration creates an application pool by using the IIS admin tools. SharePoint 2010 differs from SharePoint 2007 in the fact that 2010 uses integrated mode as opposed to classic mode. You will see evidence of this in the $appPool output when you examine the ‘managedPipelineMode’ property.

Notice in this example that we are using the New-WebAppPool cmdlet to create the application pool. If you intend to create an application pool to host a content web application, you should the New-SPWebApplication cmdlet discuss in the next section.

# Import the IIS Cmdlets

Import-Module WebAdministration

# Set the variables

$name = “IISWebAppPool”

# Call the cmdlets

$appPool = New-WebAppPool $name

$appPool|Select *

PSPath : WebAdministration::\\SHARED-SPS\AppPools\ IISWebWebAppPool

PSParentPath : WebAdministration::\\SHARED-SPS\AppPools

PSChildName : IISWebWebAppPool

PSDrive : IIS

PSProvider : WebAdministration

PSIsContainer : True

name : IISWebAppPool

queueLength : 1000

autoStart : True

enable32BitAppOnWin64 : False

managedRuntimeVersion : v2.0

managedRuntimeLoader : webengine4.dll

enableConfigurationOverride : True

managedPipelineMode : Integrated

CLRConfigFile :

passAnonymousToken : True

startMode : OnDemand

state : Started

applicationPoolSid : S-1-5-82-1517038176-2514250230-1636255725-1940432224-2879398816

processModel : Microsoft.IIs.PowerShell.Framework.ConfigurationElement

recycling : Microsoft.IIs.PowerShell.Framework.ConfigurationElement

failure : Microsoft.IIs.PowerShell.Framework.ConfigurationElement

cpu : Microsoft.IIs.PowerShell.Framework.ConfigurationElement

workerProcesses : Microsoft.IIs.PowerShell.Framework.ConfigurationElement

ItemXPath : /system.applicationHost/applicationPools/add[@name=’IISWebAppPool’]

Attributes : {name, queueLength, autoStart, enable32BitAppOnWin64…}

ChildElements : {processModel, recycling, failure, cpu…}

ElementTagName : add

Methods : {Start, Stop, Recycle}

Schema : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema

While this application pool can be used by SharePoint, if you need to create a new application pool to be used with a particular web application, then you should use the New-SPWebApplication cmdlet as shown in the next section.

Creating Application Pools for SharePoint Content Web Applications

With the release of SharePoint 2010 came a very large set of cmdlets for administrating it. One of those commands is the New-SPWebApplication cmdlet that we demonstrate below. One of the benefits of this cmdlet is that it gives you the opportunity to create a new application pool with the content web application. Once the web application is creates, I output the ApplicationPool property so that you can examine its contents. Note the type. You will see that this application pool inherits from the Microsoft.SharePoint.Administration.SPApplicationPool Class. This is important to keep in mind as in the next section; you will find that the application pools used to host the Service Application end points uses an entirely different class for its application pools.

# Set the variables

$siteName = “PowerShell for SharePoint”

$port = 80

$hostHeader = “lab.ps4sp.com”

$url = http://lab.ps4sp.com”

$appPoolName = “MyNewSPAppPool”

$managedAccount = “Shared\spservice”

$dbServer = “Shared-SPS”

$dbName = “PS4SP_SP2010_LAB_ContentDB”

$allowAnonymous = $true

$authenticationMethod = “NTLM”

$ssl = $false

# Create the web application

$webApp = New-SPWebApplication -Name $siteName `

-Port $port `

-HostHeader $hostHeader `

-URL $url `

-ApplicationPool $appPoolName `

-ApplicationPoolAccount (Get-SPManagedAccount “$managedAccount”) `

-DatabaseName $dbName `

-DatabaseServer $dbServer `

-AllowAnonymousAccess: $allowAnonymous `

-AuthenticationMethod $authenticationMethod `


#Get details of application pool


CurrentIdentityType : SpecificUser

CurrentSecurityIdentifier : S-1-5-21-1164618842-3663998900-3839706364-1107

ManagedAccount : SPManagedAccount Name=managed-account-S-1-5-21-1164618842-3663998900-3839706364-1107

ProcessAccount : S-1-5-21-1164618842-3663998900-3839706364-1107

Username : SHARED\spservice

Password :

SecurePassword :

IsCredentialUpdateEnabled : True

IsCredentialDeploymentEnabled : True

Name : Microsoft.IIs.PowerShell.Framework.ConfigurationElement

TypeName : Microsoft.SharePoint.Administration.SPApplicationPool

DisplayName : Microsoft.IIs.PowerShell.Framework.ConfigurationElement

Id : 1f6c2276-2404-4f1b-8997-fb802198c3f7

Status : Online

Parent : SPWebService

Version : 16027

Properties : {}

Farm : SPFarm Name=Shared_SP2010_Config

UpgradedPersistedProperties : {}

So now you may be wondering why I introduced the IIS Web Application Pools section, if you can use the New-SPWebApplication cmdlet to create your application pools. The simple fact is that as of the time of this writing, Microsoft hasn’t yet provided use with a set of cmdlets to manage these application pools, so if you would like to start, stop, restart, or remove them, then you would do so as if they were the IIS Web application pools.

# Import the IIS Cmdlets

Import-Module WebAdministration

# Set the variables

$name = “MyNewSPAppPool”

# Restart the Applicaiton Pool

Restart-WebAppPool -Name $name

# Check the state

Get-WebAppPoolState $name

# Turn it Off

Stop-WebAppPool -Name $name

# Check the state

Get-WebAppPoolState $name

# Turn it back on

Start-WebAppPool -Name $name

# Check the state

Get-WebAppPoolState $name






Service Application End-Point Application Pools

Now that we have discovered the first type of application pool, we now introduce the second. With the beta release of SharePoint 2010, Microsoft released a series of cmdlets that managed application pools that hosted service application end-points: New-SPIisWebServiceApplicationPool, Get-SPIisWebServiceApplicationPool, Set-SPIisWebServiceApplicationPool, and Remove-SPIisWebServiceApplicationPool. Some time prior to RTM, these cmdlets were renamed to New-SPServiceApplicationPool, Get-SPServiceApplicationPool, Set-SPServiceApplicationPool, and Remove-SPServiceApplicationPool.

It is important to know that the application pools managed by these cmdlets are not intended for content web applications. In fact, through Central Administration, you cannot create a content web application that is hosted by a SPIisWebServiceApplicationPool (SPServiceApplicationPool). While this is possible to do in PowerShell, it is not supported!!!

To show some of the property difference between the standard application pools and those created to host the service application end-points, we create an application pool using the New-SPServiceApplicationPool below. Notice the class type for the application pools is Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool.

# Set the variable

$spName = “SharePoint Portal App Pool”

$managedAccount = “Shared\spservice”

# Create a new Application Pool using the SharePoint cmdlet

$appPool = New-SPServiceApplicationPool -Name $spName -Account (Get-SPManagedAccount “$managedAccount”)

# Write Output to screen

$appPool|select *

ProcessAccountName : SHARED\spservice

Name : SharePoint Portal App Pool

ProcessAccount : S-1-5-21-1164618842-3663998900-3839706364-1107

TypeName : Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool

DisplayName : SharePoint Portal App Pool

Id : 7045ac1f-a612-4ad9-8a66-60243587eaf5

Status : Online

Parent : SPIisWebServiceSettings Name=SharePoint Web Services

Version : 12027

Properties : {}

Farm : SPFarm Name=Shared_SP2010_Config

UpgradedPersistedProperties : {}

Get a List of Application Pools Using PowerShell

To further show the difference between these two types, we examine the output from the Get-SPServiceApplicationPool cmdet. Notice that in your environment, you will only get back application pools that can host service application end-points.


Name ProcessAccountName


SecurityTokenServiceApplicationPool Shared\sqlservice

SharePoint Web Services Default Shared\SPService

SharePoint Web Services System Shared\sqlservice

To find the application pools associated with content web applications, use the Get-SPWebApplication cmdlet.

foreach($i in Get-SPWebApplication)


$i.ApplicationPool|Format-Table -Property Name,UserName


Name Username


SharedAppPool Shared\SPService

SharedPubsAppPool Shared\SPService

.NET Reflector – Decompiled Code


[Guid(“B8369089-08AD-4978-B1CB-C597B5E90F64”), SharePointPermission(SecurityAction.InheritanceDemand, ObjectModel=true), SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true)]

public class SPApplicationPool : SPProcessIdentity


// Methods

public SPApplicationPool();

public SPApplicationPool(string name, SPWebService service);

protected internal virtual void OnPasswordChange(SPManagedAccount.EventType eventType);

public override void Provision();

internal void ProvisionInternal(SecureString sstrPassword);

internal void Recycle();

public override void Unprovision();

public void UnprovisionGlobally();

public override void Update();

public virtual void UpdateCredentials(string formerUsername);


[Guid(“F9338406-BA5D-456B-8502-E9E195DDC328”), SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true), SharePointPermission(SecurityAction.InheritanceDemand, ObjectModel=true)]

public sealed class SPIisWebServiceApplicationPool : SPPersistedObject


// Fields

private const string DefaultSystemApplicationPoolName = “SharePoint Web Services System”;

private bool m_IdentityChanged;


private IdentityType m_IdentityType;


private SPManagedAccount m_ManagedAccount;


private SPIisWebServiceApplicationPoolOptions m_Options;

private static readonly object s_SynchronizationLock;

// Methods

static SPIisWebServiceApplicationPool();

public SPIisWebServiceApplicationPool();

private SPIisWebServiceApplicationPool(string name, SPIisWebServiceSettings parent, IdentityType identityType, SPManagedAccount managedAccount, SPIisWebServiceApplicationPoolOptions options);

internal void BeginProvision(SPIisWebServiceApplicationPoolProvisioningOptions options);

internal static SPIisWebServiceApplicationPool Create(SPFarm farm, string name, SPProcessAccount processAccount);

private static SPIisWebServiceApplicationPool Create(SPFarm farm, string name, SPProcessAccount processAccount, SPIisWebServiceApplicationPoolOptions options);

internal static SPIisWebServiceApplicationPool EnsureSecurityTokenServiceDefault();

internal static SPIisWebServiceApplicationPool EnsureSystemDefault();

internal static SPIisWebServiceApplicationPool GetInstance(SPFarm farm, string name);

public SecurityIdentifier GetSecurityIdentifier();

internal void ProvisionLocal();

internal void ProvisionLocal(SPIisWebServiceApplicationPoolProvisioningOptions options);

private void RaiseProcessIdentityChangedEvent();

internal void UnprovisionLocal();

public override void Update();

internal void UpdateDependentApplications();

public static SPIisWebServiceApplicationPool UpgradeFromProcessIdentity(SPProcessIdentity processIdentity, string name);

// Properties

internal IdentityType CurrentIdentityType { get; }

internal string IisObjectName { get; }

internal SPManagedAccount ManagedAccount { get; }

public string Name { get; }

public SPProcessAccount ProcessAccount { get; set; }

// Nested Types


private enum SPIisWebServiceApplicationPoolOptions






4 thoughts on “SharePoint and the Various Application Pools

  1. Shannon, Has the command new-SPServiceApplicationPool changed in RTM? I am trying to access the help files and it doesn’t appear that it recognizes it.

  2. I wish my issue was that simple. I am actually doing this in a script by using the “Add-PsSnapin Microsoft.SharePoint.PowerShell” command. I was thinking about this last night and I think it might have something to do with the fact that I am using beta2 bits because I am working on recreating an upgrade situation for a client. For my current purposes, I will just use the GUI. Thanks Shannon! Have fun at MCM training.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s