Fun with SharePoint Service Application Pools!


The blog referenced in the resource section below does a great job at demonstrating how to create a new SharePoint Web Application Pool and associate it with the Web App using PowerShell. However, as mentioned in the blog the process is a little different for Service Applications. The following information is just a quick demonstration on how to create a new service application app pool, and re-associate the existing service app to the new pool, then delete the old pool.

The Fun Stuff:

# The following commands are available when working with SharePoint Service Application Pools.
# New-SPServiceApplicationPool
# Get-SPServiceApplicationPool 
# Set-SPServiceApplicationPool
# Remove-SPServiceApplicationPool

# Check to ensure Microsoft.SharePoint.PowerShell is loaded  
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
 if ($snapin -eq $null) {
 Write-Host "Loading SharePoint Powershell Snapin"
 Add-PSSnapin Microsoft.SharePoint.Powershell

#Get the Service App you are working with and store it in a variable. 
Get-SPServiceApplication | FL DisplayName

#Pick which Service App you wish to modify from the list generated above

#Add the display name to the {$_.Name -eq " "} below
$spsvcapp = Get-SPServiceApplication | where {$_.Name -eq "BDC Service APP"}

#run $spsvcapp alone to ensure you have bound to the correct application.

# Note: 
# For the next command, the "-account" used below should be Managed account in SharePoint. 
# Before to executing the script use "New-SPManagedAccount" if a new account will be created.
# Example:
# $cred = Get-Credential
# New-SPManagedAccount -Credential $cred

#Time to create to new App Pool
$newpool = New-SPServiceApplicationPool -Name "New_BDC_AppPool" -Account "mylab\spservice"

#Store the old App Pool in a variable.
$oldapppool = $spsvcapp.ApplicationPool

#Did it store properly?

#Now associate the new app pool to the exiting service app.
$spsvcapp.ApplicationPool = $newpool

#Removing the old App Pool if necessary.
Remove-SPServiceApplicationPool $oldapppool


Create a SharePoint Application Pool using PowerShell





Comments (0)

Skip to main content