2 minute read

List all your syncronized libraries in OneDrive for Business using PowerShell

Sometimes it can be useful to be able to quickly get an overview of which libraries you have set up synchronization via OneDrive for Business for.

To my knowledge, Microsoft 365 does not yet have the ability to store this information somewere in the cloud, which would have made for example a replacement of your computer very easy.

I found a UserVoice on the subject here, so feel free to leave a vote if you find a solution like this helpful for you and your organization, so maybe it will come in the future.

Yes, there are the AutoMountTeamSites, which allows you as a IT-administrator to configure specific SharePoint Team Site Libraries your end-users to sync automatically the next time they log-in.

Back to my function. Information about synced libraries in OneDrive for Business is stored in the registry, under the following path:


Here you’ll see (based on number of syncronized libraries), some keys/folders with some wierd looking names. All of these contains information about each of your current syncronized library. The function will simply get all registry entries contained in the OneDrive registry subkey, and store each of them in a PSCustomObject.

To use the function, import or dot-source the script into your PowerShell session, and then type Get-ODfBSyncLibrary . Result:

PS C:\WINDOWS\system32> Get-ODfBSyncLibrary

https://fabrikam.sharepoint.com/sites/Projects/Shared documents/

Hint: If you apply the -Detailed switch, the function will return more detailed information about each entry.

PS C:\WINDOWS\system32> Get-ODfBSyncLibrary -Detailed | Format-List

Url              : https://contoso-my.sharepoint.com/personal/john_doe_contoso_com/Documents/
MountPoint       : C:\Users\John Doe\OneDrive - Contoso Ltd
LibraryType      : Mysite
LastModifiedTime : 10.03.2021 17:45:45

Url              : https://fabrikam.sharepoint.com/sites/Projects/Shared documents/
MountPoint       : C:\Users\John Doe\OneDrive - Fabrikam Inc
LibraryType      : Teamsite
LastModifiedTime : 10.03.2021 17:45:48

As you can see in the example above, the function will return the Url, MountPoint, LibraryType, and the LastModifiedTime from each of your syncronized library. Look at the different MountPoint. Mysite equals OneDrive for Business and Teamsite equals SharePoint Document Libraries.

From this point on, the possibilities (as with PowerShell in general:blush: ) of further use is endless. You can easily export this information into a text file, send it out via an email or maybe use PSexec to run this function on multiple remote computers to collect this information from different users throughout your organization?

The function is found on my GitHub repo:

My function does not return any information about the sync status of the different libraries, so if this is functionality you are looking for, you could check this article out on the Microsoft Tech Community.