# Sync multiple sites to explorer via PowerShell

### Prepare CSV

Create CSV with these columns. This information is needed to start the Sync Process (HTTP-Call on odopen://, see in PowerShell script) along with the UsersID and UsersUPN.

<table border="1" id="bkmrk-column-%28property%29-ex" style="border-collapse: collapse; width: 102.716%; height: 220.125px;"><colgroup><col style="width: 19.2831%;"></col><col style="width: 48.7021%;"></col><col style="width: 32.0148%;"></col></colgroup><tbody><tr style="height: 43.125px;"><td style="height: 43.125px;">**Column (Property)**</td><td style="height: 43.125px;">**Example**</td><td style="height: 43.125px;">**How to get value**</td></tr><tr style="height: 35.4px;"><td style="height: 35.4px;">url</td><td style="height: 35.4px;">[https://lucanoahcaprez.sharepoint.com/sites/teamsite1234](https://lucanoahcaprez.sharepoint.com/sites/teamsite1234)

</td><td style="height: 35.4px;">Export from SharePoint Admincenter

</td></tr><tr style="height: 35.4px;"><td style="height: 35.4px;">siteid</td><td style="height: 35.4px;">39r18c7a-11a1-5acf-813e-784339a741de

</td><td style="height: 35.4px;">Export from SharePoint Admincenter

</td></tr><tr style="height: 35.4px;"><td style="height: 35.4px;">webid</td><td style="height: 35.4px;">61b9a58e-30e1-4069-9417-843a0938a6a1

</td><td style="height: 35.4px;">Always the same (static)

</td></tr><tr style="height: 35.4px;"><td style="height: 35.4px;">listid</td><td style="height: 35.4px;">0b947fb2-6cde-4be2-a801-61a7642a5186

</td><td style="height: 35.4px;">Always the same (static)

</td></tr><tr style="height: 35.4px;"><td style="height: 35.4px;">sitename</td><td style="height: 35.4px;">Team Site 1234

</td><td style="height: 35.4px;">Export from SharePoint Admincenter

**Attention:** This has to be UTF-7 encoded (no ä, ö, ü, é, è, etc. included).

</td></tr></tbody></table>

Copy template here.

```
url;siteid;webid;listid;sitename
https://lucanoahcaprez.sharepoint.com/sites/teamsite1234;39r18c7a-11a1-5acf-813e-784339a741de;61b9a58e-30e1-4069-9417-843a0938a6a1;0b947fb2-6cde-4be2-a801-61a7642a5186;Team Site 1234
```

### Run script on client

This script can be run on the client to sync the provided sites in the csv.

```powershell
$SiteList = Import-Csv -Delimiter ";" -Path "C:\LocalData\MultipleSiteSync.csv"

$userid = "<userid>"
$userEmail = "<userupn>"

Foreach($Site in $SiteList){
    $SiteId = $Site.siteid
    $WebId = $Site.webid
    $Listid = $Site.listid
    $WebTitle = $Site.sitename
    $WebUrl = $Site.url
   
    Start-Process "odopen://sync?userId=$userid&userEmail=$UserEmail&isSiteAdmin=0&siteId=$SiteId&webId=$WebId&webTitle=$WebTitle&webTemplate=64&webUrl=$WebUrl&onPrem=0&libraryType=3&listId=$ListId&listTitle=Dokumente&scope=OPENLIST"
    Start-Sleep -seconds 10
}
```