Modify your SharePoint application pools using PowerShell

Sometimes your application pools need some maintenance. For instance changing their identity or if you wish to bundle some IIS sites to run under the same application pool so you won’t lose memory to overhead.

Changing the identity of the application pool is rather easy. You can use central admin or the Set-SPServiceApplicationPool cmdlet. Modifying an already running web application’s pool is a little bit different. There’s no cmdlet out of the box, so you’ll have to use the object model. There are 2 great scripts already available on technet. There’s one for changing the application pool, and another one for deleting the unused application pool.

If you wish to just copy paste directly into PowerShell, you can use the scripts below:

Note: the target applicationpool has to be created using SharePoint or else it won’t be recognized!

# Changing an application pool
$apppool = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplicationPools | where {$_.Name -eq "Applicationpoolname found in IIS"}
$webapp = get-spwebapplication -Identity http://sharepoint
$webapp.Applicationpool = $apppool
$webApp.Update()
$webApp.ProvisionGlobally()
# Deleting an application pool
$apppool = [Microsoft.SharePoint.Administration.SPWebService]::ContentService.ApplicationPools | where {$_.Name -eq "Applicationpoolname found in IIS"}
$apppool.UnProvisionGlobally()
Advertisements

One thought on “Modify your SharePoint application pools using PowerShell

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )

w

Connecting to %s