다음을 통해 공유


Fun with SharePoint Service Application Pools!

Summary

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.
$spsvcapp

# 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?
$oldapppool

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

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

Resources

Create a SharePoint Application Pool using PowerShell
https://blogs.technet.microsoft.com/fromthefield/2014/03/26/create-a-sharepoint-application-pool-using-powershell

New-SPManagedAccount
/en-us/powershell/module/sharepoint-server/new-spmanagedaccount?view=sharepoint-ps

Get-SPServiceApplicationPool
/en-us/powershell/module/sharepoint-server/get-spserviceapplicationpool?view=sharepoint-ps

New-SPServiceApplicationPool
/en-us/powershell/module/sharepoint-server/new-spserviceapplicationpool?view=sharepoint-ps

Remove-SPService​Application​Pool
/en-us/powershell/module/sharepoint-server/remove-spserviceapplicationpool?view=sharepoint-ps