Content Migration

When it comes to content migration we have the option to write code (script) or use a migration toolset or a combination of both, thus it is important to identify the appropriate toolset based on “ease of use” and what we need to achieve.
I have evaluated several migration toolsets however, in this blog I am going with Sharegate as I have extensively used this product recently.

Sharegate is a toolset used to  “Manage, Migrate and Secure SharePoint & Office 365”. 

We will look at migrating a document library in SharePoint O365 environment to another document library in the same environment and see how we can use Sharegate to speed up this process. I will incorporate some of my experiences, working with a customer on a document migration strategy.

What are we trying to achieve?
              Migrate document libraries in SharePoint and apply metadata in the process using a combination of excel and PowerShell scripting along with Sharegate. 

sharegate-content-migration-using-powershell

Image 1


 

  1. Select the Source document library to Migrate.
  2. Create the spreadsheet using Sharegate “Export to Excel” function.
  3. Update the Metadata within the excel spreadsheet (this can be done manually or by a console app).
  4. Using Sharegate PowerShell automate the Import/Migration process.

 

To achieve this, we need to do the following:

  1. Logon to Sharegate and click on the “Copy SharePoint Content” option as depicted below.
Sharegate1.png

Image 2

2. Connect using  your O365 SharePoint tenant, using your credentials.

3. Below, as you can see I have a bunch of test documents that I need to migrate from source document library to the target document library.

Sharegate 3 1.png

Image 3

4. Click on Excel to export an excel spreadsheet (to update the metadata columns).

5. Select the documents that you would like to copy across, however before starting to copying you will need to set up a custom property template as below:

Property templates allow you to select the options used for the bulk edition and to set custom actions for all of the list or library’s columns.

sharegate4

Image 4

6. Give the template a name and set up the template properties as below as per your requirements.

sharegate5

Image 5

7. When you click on “Save & Start” you can start copying the files across using the Sharegate UI.

Using PowerShell script to automate this migration process

  1. Save the Excel file locally, for e.g. “MigrationTest.xlsx”
Sharegate excel.png

Image 6

2. Update the columns in the excel spreadsheet with the appropriate metadata and save the file.

3. Click on the Sharegate PowerShell  to open the PowerShell as shown in the below Image.

sgps

Image 7

4. Run the below script.

PowerShell script using Sharegate’s “Copy-Content” cmdlet :

#PowerShell Script to migrate documents using Sharegate PowerShell
#Connection to O365 account
$mypassword = ConvertTo-SecureString "******" -AsPlainText -Force
$srcSite = Connect-Site -Url "https://yourtenant.sharepoint.com/sites/test/ /" -Username "user@domain.com.au" -Password $mypassword
Write-Host "Connected to source"
$dstSite = Connect-Site -Url "https:// yourtenant.sharepoint.com/sites/test2/DestDocLib/" -Username "user@domain.com.au" -Password $mypassword
Write-Host "Connected to Target"
Write-Host $srcList
$srcList = Get-List -Name "SrcDocLib" -Site $srcSite
Write-Host $dstList
$dstList = Get-List -Name "DestDocLib" -Site $dstSite
$Template = “TestTemplate"
Write-Host "Copying..."
Copy-Content -TemplateName $Template -SourceList $srcList -DestinationList $dstList -ExcelFilePath "C:\POC\MigrationTest.xlsx"
Write-Host "Done Copying"

 

PowerShell to “export to excel” from Sharegate

As of today, Sharegate does not have an “export to excel” script as yet, this step has to be done through the Sharegate UI. I have talked to the Sharegate support team and they came back to me saying, “this is one of the most requested feature and will be released soon“. Please refer to the Sharegate documentation for updates on new features: http://help.share-gate.com/

Conclusion

Using Sharegate and PowerShell we can automate the document migration and metadata tagging. Going further you can create a number of excel export files using Sharegate and script to iterate through each excel file as input parameter to the above PowerShell script.
 
 

Category:
PowerShell, SharePoint, Uncategorized
Tags:
,

Join the conversation! 3 Comments

  1. Hi,
    Thank you for this post it is very helpful. We are migrating files from a number of document libraries into totally new ones as we are changing the IA significantly. As a result files from one document library can be going to multiple destinations. Based on what I am seeing it appears we need a spreadsheet and a template for every permutation of source and destination libraries unless of course we can read a base spreadsheet and change the source and destination on the fly as well as generate an excel file on the fly. I was wondering if this is something you may have looked at.
    By the way I am a fellow Aussie now living in Canada.
    Thank you in advance for any help you can provide.

  2. Nice article. It’s 2018, we’re still waiting for that export script…
    Aside from that, do you know how to flatten the folder hierarchy with Powershell? It’s part of the “Advanced” functions via the ShareGate GUI, but I can’t find anything resembling that in the powershell commandlets. I am not proficient in Powershell, so I may have overlooked something that seems obvious you…

    • Hi Russell,
      Thanks for your comment! You may have to manipulate the excel export from Share-gate to handle the folder hierarchy. As Share-gate maintains the folder path from the source.
      Regards, Will

Comments are closed.