Skip to main content
All CollectionsMigratePowerShellPowerShell Tips and tricks
Export and import Explorer connections in PowerShell
Export and import Explorer connections in PowerShell
Updated over 4 months ago

To share your Explorer connections, you can use Export-Connections to export your connections and a foreach loop to import them with PowerShell.

Export Explorer connections

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

# Import the Sharegate module
Import-Module Sharegate

# Export Sharegate connections to a CSV file
Export-Connections -Path "C:\ExportedConnections.csv"

Adjust the path to export the file to the location of your choice with the desired name and extension. You can save it as a .csv or .xlsx file.

Run your script when it's properly adjusted.

Import Explorer connections

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

# Import the Sharegate module
Import-Module Sharegate

# Define the path to the exported connections CSV file
$csvFile = "C:\ExportedConnections.csv"

# Import the CSV file into a table
$table = Import-Csv $csvFile

# Define user credentials
$myUsername = "myusername"
$myPassword = ConvertTo-SecureString 'mypassword' -AsPlainText -Force

# Loop through each row in the CSV table and connect to the specified SharePoint site
foreach ($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 exported.

  • $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 Explorer in ShareGate Migrate.

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

Did this answer your question?