Summary: Use these PowerShell cmdlets to migrate to SharePoint Online.
Today’s post is from Christopher Weaver, who is a Microsoft Premier Field Engineer (PFE) and focuses on SharePoint and Office 365 solutions for large enterprise Premier customers. He has been doing PowerShell and SharePoint with Microsoft for nine years. In his spare time, he enjoys backpacking, hiking, kite surfing, and spending time with his kids and dog. You can follow him on his blog at https://blogs.technet.microsoft.com/christwe/.
As we prepare our SharePoint Online environment for migration, we will need to be able to manage site collections and the web templates that we use to create those site collections. First, let’s look at cmdlets that are available in this category.
Get-SPOWebTemplate – Gets all site templates that are available or gets specific templates based on different parameters. In the example, we get the default team site web template.
Get-SPOWebTemplate -Name STS#0
Get-SPOSite – Gets one or more site collections. You could then take that object and pass it to another cmdlet or use its members.
New-SPOSite – Creates a new site collection. You can use its many parameters to set several properties automatically at creation time.
New-SPOSite -url https://mmr258720.sharepoint.com/sites/test1 -Owner firstname.lastname@example.org -StorageQuota 26214400
Remove-SPOSite – Moves a site collection to the recycle bin to permanently delete the site collection. Before the site is permanently deleted, you need to run the Remove-SPODeletedSite command or wait approximately 90 days. During this period, the site collection will not count towards storage quotas.
Set-SPOSite – Lets you set many different properties on an existing site collection.
Set-SPOSite https://mmr258720.sharepoint.com/sites/mr -lockstate NoAccess
Test-SPOSite – Runs one or several different health rules, and then returns the results.
This command only produces a report; it does not make changes to your site. After you have reviewed the report and are comfortable with the repairs, run the
Repair-SPOSite cmdlet, which I describe below.
The site health rules are:
|Rule name||Rule ID|
|Conflicting Content Types||befe203b-a8c0-48c2-b5f0-27c10f9e1622|
|Missing Parent Content Types||a9a6769f-7289-4b9f-ae7f-5db4b997d284|
|Missing Site Templates||5258ccf5-e7d6-4df7-b8ae-12fcc0513ebd|
|Unsupported Language Pack References||99c946f7-5751-417c-89d3-b9c8bb2d1f66|
|Unsupported MUI References||6da06aab-c539-4e0d-b111-b1da4408859a|
Repair-SPOSite – Runs the health tests from the Test-SPOSite command and, when possible, automatically repairs issues. After the command finishes running, it provides a report that includes results.
Upgrade-SPOSite – Performs site collection upgrade by default. This is a build-to-build upgrade. On occasion, it could become a version-to-version upgrade when you must run a health check in repair mode to ensure that a site collection can be upgraded.
As we prepare to migrate, we must create the new site collection to which you’ll migrate. So, let’s look at the cmdlets that make this possible. The first cmdlet is
New-SPOSite because this command creates the site collection. Let’s look at the available parameters.
- Url – A required parameter that represents the URL for your site collection. Make sure that the managed path is valid for your tenant.
- Owner – A required parameter that represents the user name of the owner, and it must be a valid user account in your tenant. You cannot use groups or distribution lists. The owner receives Full Control of the site collection. This user should receive some high-level training to ensure that he doesn’t do undesired damage.
- StorageQuota - A required parameter that represents the maximum size in MB that the site collection will grow. This cannot exceed the tenant maximum and includes items like the Recycle Bin.
- Template – Although this is an optional parameter, I recommend that you set it ahead of time. If you don’t set it, the first person who hits the site collection with the correct permissions will get to pick the template for you. You can pick a valid template by running the
- CompatibilityLevel – Although this is an optional parameter, I recommend you set this ahead of time.
NOTE: If you have a site collection with the same URL in the Recycle Bin, this cmdlet will fail with an error that looks like this.
New-SPOSite : A site already exists at url https://tenant.sharepoint.com/sites/sitecollection
The solution is to restore from the Recycle Bin or permanently delete it.
If you have been following my last few articles, you should now be able to connect to the SharePoint Online service, manage the tenant, and manage/create site collections. The next step will be how to use the migration API. Watch for that next.
I invite you to follow the Scripting Guys on Twitter and Facebook. If you have any questions, send email to them at email@example.com, or post your questions on the Official Scripting Guys Forum.
Premier Field Engineer