SHAREPOINT MIGRATION 5 MIN READ

How to Migrate SharePoint Libraries in PowerShell and Sharegate

Aaron Chatham
WRITTEN BY AARON CHATHAM
Since the publication of this article, Sharegate has updated and unified the migration interface of its Desktop Tool. The following screenshots may no longer be accurate, we are working on updating them.

The Sharegate PowerShell commands now allow users to move multiple SharePoint libraries and lists by simply using the Copy-List cmdlet. Today kids we will focus on the power of this cmdlet with step-by-step instructions on how to migrate multiple lists and libraries in a few PowerShell lines. This process can also be automated by creating a script and configuring a new task through Windows Task Scheduler. For more information on Sharegate automation, check out “Schedule your SharePoint migration using PowerShell and Sharegate”.

To get started, we will highlight the steps needed in order for this to work:

  1. Import the Sharegate Module

  2. Connect to the destination site

  3. Migrate the list from the source to the destination site

  4. Watch the magic of Sharegate and PowerShell make your job simple!

Multiple SharePoint libraries migration with powershell

Importing the PowerShell Sharegate Module

The first step is to open of PowerShell and import the Sharegate module. This can be done one of two ways.

                Option 1 – Type Import-Module Sharegate into the Management Shell as shown above.

Option 2 – Launch PowerShell in the Sharegate application by selecting the PowerShell icon located on the ribbon in the SharePoint Migration section.

Multiple SharePoint libraries migration with powershell

Note: If when trying to import the Sharegate Module you get the following message:

Import-Module: The version of the loaded PowerShell is ‘2.0’. The module ‘C:Program Files (x86)Sharegate MigrationSharegateSharegate.psd1’ requires a minimum PowerShell version of ‘3.0’ to execute. Please verify the installation of the PowerShell and try again.

it means you have an older version of PowerShell and need to upgrade to version 3.0. For more information on how to get version 3.0, check out this Microsoft article Installing Windows PowerShell.

Multiple SharePoint libraries migration with powershell

Connect to the SharePoint Migration Destination Site

Now that we have imported the Sharegate module into our current PowerShell window, we will connect to the destination site by creating a variable named $dstSite. This variable will use the Sharegate cmdlet Connect-Site along with the Url attribute to simply connect to the site we want to move the libraries too. In our case we will be connecting to the http://myfarm1/sites/mydestinationsite as our destination of choice.

Multiple SharePoint libraries migration with powershell

Migrating the SharePoint Libraries from the Source Site to the Destination Site

The last step we have to execute before we look like expert PowerShell geeks, is to tell PowerShell where the source site is located and what lists (or in our case libraries) we want to copy over to the destination site. Let’s take a look at the PowerShell code and how it works...

Multiple SharePoint libraries migration with powershell

First things first, we must connect to the source site http://myfarm1/sites/mysourcesite by specifying the Url attribute. Once we are connected to the source, we then can use the Copy-List cmdlet along with the Name attribute to identify which libraries we want to copy. In our example, we will be copying the MyTitle* and MySpecificTitle libraries to the destination site. As we have mentioned previously, the variable $dstSite has been created to call the destination site.

Multiple SharePoint libraries migration with powershell

There you go! It’s as simple as 1,2,3.  A Sharegate migration is now simpler than ever with the new PowerShell commands. As we have seen in this post, the commands such as Connect-Site and Copy-List are easy to remember cmdlets that are sure to make your job easier. To learn more about all the available Sharegate PowerShell commands check out our documentation on the subject.


For more resources on migrating lists and libraries you can read the following:


Hey, got another minute?

Ensure a seamless move to Office 365. Use our checklist to avoid any costly mistakes.

The Ultimate Office 365 migration checklist
ShareGate Logo White

Benefit from the full potential of the cloud.

Businesses have to move to the cloud and adapt to it. That’s a fact. ShareGate helps with that.

See how