SharePoint 2013: working with web application pools: adding, removing and modifying
Introduction
In this posting, I present the steps for performing routine tasks with web application pools, including adding, removing and modifying. This posting integrates postings and comments by others and my own notes on this and related subjects.
Reviewing
Log into a SharePoint 2013 server using the SharePoint Setup User Administrator account (eg, spAdmin). This is the same account that you (should have) used to perform the initial farm installation and configuration.
This is important in that the changes you will be making will be to the farm configuration database; and, by default, only this account has the privileges necessary to make such changes.
Launch an elevated SharePoint Management shell.
Execute the following commands, making appropriate revisions:
-
([Microsoft.SharePoint.Administration.SPWebService]::ContentService).ApplicationPools | Sort-Object Name | Select-Object Name, ID, UserName, Status, parent | Format-Table -Auto
To view other properties, use the Get-Member command to find them and then edit the above as appropriate.
Adding
Now, using the same management shell, execute the next few commands to create the new pool:
01.$WebAppURL = "[Your site URL]" 02.$NewAppPoolName = "[NameOfNewAppPool]" 03.$NewAppPoolIdentity = "[IdentityOfnewAppPool]" 04.$password = "[service account password" 05.$SvcAcctPW = ConvertTo-SecureString -String $password -AsPlainText -Force 06.$Service = [Microsoft.SharePoint.Administration.SPWebService]::ContentService 07.$NewAppPool = New-Object Microsoft.SharePoint.Administration.SPApplicationPool($NewAppPoolName,$Service) 08.$NewAppPool.CurrentIdentityType = "SpecificUser" 09.$NewAppPool.Username = $NewAppPoolUserName 10.$NewAppPool.SetPassword($SvcAcctPW) 11.$NewAppPool.Provision() 12.$NewAppPool.Update($true) 13.$NewAppPool.Deploy()
The new application pool will be available immediately
To verify that the new web application pool has been created, first log into one of the farm WFEs hosting the web application using any administrator account.
Next, launch IIS Manager.
In the Connections tree, expand Application Pools.
Removing
Now, using the same management shell, execute the following commands to remove the web application pool:
1.$apppool = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplicationPools | where {$_.Name -eq "[name of web application pool]"} 2.$apppool.UnProvisionGlobally()
The prompt returns quickly. However, this doesn't mean that the application pool has already been removed. This is because this task executes as a job and therefore will take a minute or two to complete. If you check IIS immediately after the prompt returns, you will likely still see the web application pool listed. Wait a bit and then try again.
Verify by first logging into one of the farm WFEs hosting the web application using any administrator account.
next, launch IIS Manager.
Then, in the Connections tree, expand Application Pools.
Modifying
First, let's review information concerning the existing web application pool. Log into a SharePoint 2013 server using the SharePoint Setup User Administrator account (eg, spAdmin). This is the same account that you (should have) used to perform the initial farm installation and configuration.
This is important in that the changes you will be making will be to the farm configuration database; and, by default, only this account has the privileges necessary to make such changes.
Launch an elevated SharePoint Management shell.
Execute the following command, making appropriate revisions:
1.$wa=Get-SPWebApplication "[YourSiteURL]" 2.$wa.ApplicationPool
This lists out all the pertinent information concerning the web application pool's identity. A useful command to remember for future reference.
Don't terminate this shell: you'll need the web application object reference ($wa) for the next steps.
Now, using the same management shell, execute the next few commands to make the change to the identity:
1.$ma=Get-SPManagedAccount -Identity "[target managed account]" 2.$wa.ApplicationPool.ManagedAccount=$ma 3.$wa.ApplicationPool.Update() 4.$wa.ApplicationPool.Deploy()
The change will be implemented immediately
To verify that the change has been made, first log into one of the farm WFEs hosting the web application - use any administrator account.
Then launch IIS Manager.
Lastly, in the Connections tree, expand Application Pools. If you still see the original identity, press F5 to refresh - no need to recycle the application pool or perform an IIS reset.
References
- Direct
- Initial deployment administrative and service accounts in SharePoint 2013
- Account permissions and security settings in SharePoint 2013
- SharePoint 2013: Service Account Configurations and Permissions
- Create a SharePoint Application Pool using PowerShell
- Delete a SharePoint Web Application Pool
- Title Application pools recycle when memory limits are exceeded. ???
- Get-SPWebApplication
- Get-SPManagedAccount
- General
Notes
- The new web application pool will not be added to the application pools associated with web applications until you execute the Update method. You can test this by executing all of the commands up to but not including the Update method, and then listing out the web application pools. Additionally, you will not see the new application pool show up in IIS Manager until after you execute the Deploy method.
- From my testing, the Remove method of [Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplicationPools object does remove the web application pool from the farm configuration database, which you can verify by executing the command in the Review section above. However, it leaves the web application pool still active in IIS. On the other hand, the UnprovisionGlobally method of an SPApplicationPools object removes both the application pool from SharePoint configuration and from IIS.
- Curiously, note that an instance of the SPApplicationPools object has a Provision method but that this method does not push the update to the WFEs. To do this, you have to execute the Provision, Update and Deploy methods in sequence. On the other hand, the single UnprovisionGlobally method of this object removes the web application pool both from SharePoint farm configuration and from IIS on all WFEs. This seems inconsistent.
- Thanks to Brendan Griffin in his posting and Henrik Tønnessen in his comment (scroll down) for helpful presentations on this topic