Wednesday, November 21, 2018

SharePoint Migration with Sharegate and PowerShell

Sharegate is a really nice tool to migrate stuff across different SharePoint version, from on-premise 2007 to the newest cloud version. But with the UI you always have to create tasks for the migration. Why not use a CSV and PowerShell to make that happen?

First of all we need a CSV. I chose this design:

type;sourceurl;destinationurl;sourceList;destinationList;sourcefolder;destinationfolder;title

You have to provide a type, currently it could be "LIST", "FOLDER" and "UNC". You also need to provide destination and source and of course a title. The title will be use to create the file name for the log. A final CSV would look like this:

Link to the raw file
The script itself is a simple one. We import the Sharegate Module for PowerShell and load the MigrationList.csv. After that we check every entry of the CSV and load the item. The "type" defines which function will get used to migrate the content.

For LIST: Copy-Content -SourceList $srcList -DestinationList $destList -ExcelFilePath $fileName
For FOLDER: Copy-Content -SourceList $srcList -DestinationList $destList -SourceFolder $sourceFolder -DestinationFolder $destinationFolder -ExcelFilePath $fileName
For UNC: Import-Document -SourceFolder $sourceURL -DestinationList $destList -ExcelFilePath $fileName

Here's the script in its entirety: You can find the repository here: Github

No comments:

Post a Comment