Move All Site Collections from One Content Database to Another

Scenario/Problem: You want to move all site collections stored in one content database to a different content database.

Solution: Use the Move-SPSite cmdlet with the Get-SPSite cmdlet.

You can pipe the results of Get-SPSite to the Move-SPSite cmdlet. Therefore, by using the ContentDatabase parameter with Get-SPSite, you can easily move all site collections from that content database to a new content database. Listing 8.18 shows a sample command line.

Listing 8.18. Moving All Site Collections from a Content Database

Get-SPSite -ContentDatabase "WSS_CONTENT_MAIN" | Move-SPSite-DestinationDatabase "WSS_CONTENT_TEAMSITES"

As with moving a single site collection, the destination database ...

Get PowerShell™ for SharePoint® 2013 How-To now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.