Monday, April 16, 2018

SharePoint 2016 TIP: how to change content database name in four steps using PowerShell

On any farm server, open an elevated SharePoint Management Shell.

Execute this commandlet to create a new content database mounted to the same web application hosting the content database you want to rename:
New-SPContentDatabase "[NewDatabaseName]" -DatabaseServer "[Alias or name of database server]" -WebApplication "[Web application URL]"
Execute this commandlet to get the names and, most importantly, IDs of all of the content databases currently mounted to that web application:
Get-SPContentDatabase -WebApplication "[Web application URL]" 
You need those IDs in order to be able to execute this commandlet that performs the actual move operation:
Get-SPSite -ContentDatabase "[OldDatabaseID]" | Move-SPSite -DestinationDatabase "[NewDatabaseID]" 
Perform an IISRESET on all farm servers hosting that web application.  Lastly, dismount the old database from the web application:
Dismount-SPContentDatabase "[OldDatabaseID]"

References

No comments: