Skip to main content
All CollectionsMigratePowerShellTips and tricks
Add site collections to the Explorer in PowerShell
Add site collections to the Explorer in PowerShell
Updated this week

You can add individual site collections one at a time in the Explorer, or you can add all the site collections from your farm or tenant by connecting to your admin center or central admin.

To connect to a number of specific site collections in the Explorer without having to do each connection individually, you can use the -AddToExplorer parameter in a PowerShell script.

Tip: You can also export and import your connections from Explorer to share them with other ShareGate Migrate users.

Index

Add a single site collection to the Explorer

Copy and paste the following script in the PowerShell application of your choice.

Import-Module Sharegate$myUsername = "myusername"$myPassword = ConvertTo-SecureString 'mypassword' -AsPlainText -ForceConnect-Site -Url "http://yourtenant.sharepoint.com/sites/yoursitecollection" -Username $myUsername -Password $myPassword -AddToExplorer

Adjust your script to make it work for you. Here are a few guidelines:

  • $myUsername and $myPassword: Replace "myusername" and 'mypassword' with your SharePoint or Microsoft 365 credentials.

  • Connect-Site: If you need to change the authentication method, you will find how to do it in the Connect Site article.

  • -URL: Replace the URL to match your site collection's URL.

Run your script once it's properly adjusted and tested.

Tip: You can have multiple Connect-Site lines with different URLs to add multiple Site Collections to Explorer with this script. If you have a lot of sites to connect to, we suggest using the CSV method below instead.

Add multiple site collections to the Explorer using a CSV

Create a CSV guide for your connections

  1. Create a new Excel document.

  2. Name the first column URL.

  3. List the URLs of all the site collections you want to add to the Explorer.
    โ€‹

    mceclip0.png
  4. Save the file as a CSV.

Create your script

Copy and paste the following script in the PowerShell application of your choice.

Import-Module Sharegate$csvFile = "C:\CSVfile.csv"$table = Import-Csv $csvFile$myUsername = "myusername"$myPassword = ConvertTo-SecureString 'mypassword' -AsPlainText -Forceforeach ($row in $table) {     Connect-Site -Url $row.URL -Username $myUsername -Password $myPassword -AddToExplorer}

Adjust your script to make it work for you. Here are a few guidelines:

  • $csvFile: Adjust the path so that it points to the CSV file you saved before.

  • $myUsername and $myPassword: Replace "myusername" and 'mypassword' with your SharePoint or Microsoft 365 credentials.

  • Connect-site: If you need to change the authentication method, you will find how to do it in the Connect Site article.

  • foreach: Loops the commands between the brackets for each row in your CSV file. In this case, it adds your connections to the Explorer in ShareGate Migrate.

Run your script once it's properly adjusted and tested.

Did this answer your question?