# Microsoft SharePoint # 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.
**Column (Property)** | **Example** | **How to get value** |
url | [https://lucanoahcaprez.sharepoint.com/sites/teamsite1234](https://lucanoahcaprez.sharepoint.com/sites/teamsite1234) | Export from SharePoint Admincenter |
siteid | 39r18c7a-11a1-5acf-813e-784339a741de | Export from SharePoint Admincenter |
webid | 61b9a58e-30e1-4069-9417-843a0938a6a1 | Always the same (static) |
listid | 0b947fb2-6cde-4be2-a801-61a7642a5186 | Always the same (static) |
sitename | Team Site 1234 | Export from SharePoint Admincenter **Attention:** This has to be UTF-7 encoded (no ä, ö, ü, é, è, etc. included). |
Requirements: Graph Explorer knowledge needed.
### Create App Registration An App Registration will be used to authenticate against Microsoft Graph API. For creating an App Registration there is an other detailed guide. ### Permissions With API Permission "Sites.Selected" you can specify on which SharePoint-Sites the App Registration will have permissions to read/write files and properties. [](https://docs.lucanoahcaprez.ch/uploads/images/gallery/2022-11/PWLimage.png) ### Get Site ID To get the site id of your sharepoint sites to to the following link in a Webbrowser: GET https://<tenantname>.sharepoint.com/sites/<sitename>/\_api/site/id Example: [https://lucanoahcaprez.sharepoint.com/sites/SPS-LNC-WebFiles-PROD/\_api/site/id](https://lucanoahcaprez.sharepoint.com/sites/SPS-LNC-WebFiles-PROD/_api/site/id) Example XML Response in Browser: [](https://docs.lucanoahcaprez.ch/uploads/images/gallery/2022-11/Mhzimage.png) ### Get Folder ID Folder IDs can be found using the graph explorer and the Site ID: GET https://graph.microsoft.com/v1.0/sites/<SiteID>/drives Example: https://graph.microsoft.com/v1.0/sites/22c1c748-f7e0-4f10-97f4-64b51694a0ca/drivesRequirements: App Registration with appropriate permissions, as described here: [Read SharePoint files ... | LNC DOCS (lucanoahcaprez.ch)](https://docs.lucanoahcaprez.ch/books/microsoft-sharepoint/page/read-sharepoint-file-information-via-graph-api)
With this tutorial, files can be read from SharePoint Online repositories automatically and without user interaction. This can be especially valuable when large accesses to files need to be made, but the budget for Azure Blob Storage, for example, is not available. It also allows very easy customization of the corresponding files in SharePoint Online, which can then be used directly in the automation. ### Preparations First of all, the app registration must be created with the appropriate permissions. This is described here: [Read SharePoint files ... | LNC DOCS (lucanoahcaprez.ch)](https://docs.lucanoahcaprez.ch/books/microsoft-sharepoint/page/read-sharepoint-file-information-via-graph-api) Then the app must be assigned the appropriate permissions on SharePoint Online once. This can be achieved with the following PowerShell code. The two upper variables must be filled in accordingly with the SharePoint Site URL and the App Registration ID. ```powershell $siteUrl = "https://Requirements: You need to work through the "Preparations" part of this manual: [Download & read files ... | LNC DOCS (lucanoahcaprez.ch)](https://docs.lucanoahcaprez.ch/books/microsoft-sharepoint/page/download-read-files-via-graph-api)
With this tutorial, files can be written to SharePoint Online repositories automatically and without user interaction. This can be especially valuable when you need an affordable place to automatically save files. It is also useful if you want to build an automation in to an existing file structure. ### Preparations Work according to this manual and complete the steps up to and including "Preparations". Afterwards, the app registration can write to the appropriately authorized SharePoint Online site without user interaction. ### Getting the Graph API Authentication With these preparations you will then be able to upload data to SharePoint Online using the Graph API. It is important that all variables are filled in appropriately and correctly. ```powershell $TenantId = "