Quantcast
Channel: John Chapman » Web | John Chapman
Viewing all articles
Browse latest Browse all 10

[SharePoint 2010] Move All My Sites – Personal Sites – From One Content Database to Another With PowerShell

$
0
0

In one of my SharePoint 2010 farms we have all of our My Sites under the same web application as our main SharePoint portal. For example, we have http://portal as our intranet portal with all of the My Sites under http://portal/personal. In this particular case, the users make heavy use of the My Sites for storing documents and such so we wanted to keep the My Sites in a separate content database while maintaining the same URL structure under the main portal site.

To accomplish this, we created a separate content database and used PowerShell to move all of the My Site site collections to the new content database. Since SharePoint creates new Site Collections under the default content database, we run this script from time-to-time in order to keep all of the My Sites in the same content database.

Here is how we accomplished this:

  1. Open Central Administration

  2. Under Application Management select Manage content databases

  3. Make sure the correct Web Application is selected and click Add a content database

  4. Give the Database a name, for instance WSS_Content_Personal, and click OK

  5. On one of the SharePoint servers in the farm open SharePoint 2010 Management Shell (PowerShell)

  6. Enter the following PowerShell command to assign the content database you are moving the My Sites from to a variable (be sure to replace WSS_Content with the name of your from database):

    $db = Get-SPContentDatabase WSS_Content

  7. Enter the following PowerShell command to review the list of sites that are included in this move to ensure nothing is included you did not intend to include (replace portal with your site name):

    Get-SPSite http://portal/personal/* -Limit ALL | where { $_.ContentDatabase -eq $db }

  8. Once you have reviewed the sites to be moved, run the following PowerShell command to move all of the Site Collections to the new Content Database (replace portal with your site name and WSS_Content_Personal with the name of the content database you are moving the sites to):

    Get-SPSite http://portal/personal/* -Limit ALL | where { $_.ContentDatabase -eq $db } | Move-SPSite -DestinationDatabase WSS_Content_Personal -Confirm:$false

  9. Once the command completes, run IISRESET on all of the SharePoint servers in the farm.

That’s it. You could also use this PowerShell command to move sites based on any filter you choose.


Viewing all articles
Browse latest Browse all 10

Trending Articles