SharePoint 2010: Using PowerShell to create Web Application Pool

You can use the following PowerShell code to create a new Application Pool for your SharePoint site

$svc = [Microsoft.SharePoint.Administration.SpWebService]::ContentService
$pool = New-Object Microsoft.SharePoint.Administration.SPApplicationPool "SharePoint App Pool", $svc
$pool.CurrentIdentityType = "SpecificUser"
$acct = Get-SPmanagedAccount DOMAIN\USER
$processAcct = [Microsoft.SharePoint.Administration.SPProcessAccount]::LookupManagedAccount($acct.Sid)
$pool.ProcessAccount = $processAcct
$pool.Provision()

The application pool will be created.

You can update an existing application’s application pool followed by this script:

$webApp = Get-SPWebApplication http://web
$webApp.ApplicationPool = $pool
$webApp.ProvisionGlobally()
$webApp.Update()

 

You can also switch a web application’s application pool to another by using the following PowerShell Script

$sourceWebAppPool = (Get-SPWebApplication http://web1).ApplicationPool
$webApp = Get-SPWebApplication http://web2
$webApp.ApplicationPool = $sourceWebAppPool
$webApp.ProvisionGlobally()
$webApp.Update()

Xin

2 thoughts on “SharePoint 2010: Using PowerShell to create Web Application Pool

  1. Need to update you, in my case it did not work, one web server had the new application pool, the second did not have it. As a result nothing worked.

Leave a Reply

Your email address will not be published. Required fields are marked *