Rename a Service Application’s database using PowerShell
While setting up a SharePoint 2013 DR environment I needed to script the renaming of databases used by service applications. Utilising the Get-SPServiceApplication cmdlet I was able to achieve this with just three lines:
$sa = Get-SPServiceApplication -Name "Managed Metadata Service" $sa.Database.Name = "New_Database" $sa.Update()
Note: It was necessary to stop the service first using the Stop-SPServiceInstance cmdlet.