MEM – Automatic Syncing of OneDrive Shared Libs via Intune

Welcome! A few months ago now, I wrote a post on how to set up OneDrive known folder move via Microsoft Intune, this week, I want to show you how you can deploy a Configuration Profile that will automatically sync a SharePoint document library via OneDrive to a Windows 10 device, this post compliments the previous OneDrive KFM provisioning post, click here to view the OneDrive KFM post, let’s get started!

UPDATED – 07/09/2022 – Added section on converting strings from Unicode to ASCII (Thanks Mark)

The old way vs the new way

On the road to modern management, the decision on what to do with user profiles and departmental data comes up very quickly, in the traditional environment we would typically have DFS file shares setup for Departmental data and Active Directory home folder created for every user (sometimes referred to U or H Drive, etc), the modern management approach is typically to migrate the end-users home folder to OneDrive and to migrate departmental shares to SharePoint document libraries, Azure Files Sync or Microsoft Teams (I won’t cover Azure files sync or MS Teams).

Home folder (U-Drive)OneDrive
DFS File SharesAzure Files Sync
SharePoint Document Libraries

This post will describe how to set-up the Windows 10 client to automatically sync the SharePoint document library.

Understanding the limits

Beware of the following when syncing SharePoint document libariries via OneDrive

  • Limit of 5000 files or folders synced to devices (in total, not OR) – I have personally seen a lot more files synced fine but you won’t be supported by Microsoft if you break this limit.
  • Limit of 1000 devices syncing a particular document library.
  • Users may have to wait up to 8 hours until their document libraries to appear on their devices, this is expected to ensure that network isn’t overwhelmed. (More on this later to reduce the 8-hour wait)

Before you begin

Before we setup our Configuration Profile within Intune, we’ll need to gather the SharePoint document library ID(s), for this example, I will use the Sales and Marketing departments library, once you’ve browsed to the lib, click sync.

Gathering the OneDrive Shared library sync ID

A window will now appear, (if you receive any prompts to open OneDrive ignore it), click Copy library ID, keep this handy.

IMPORTANT – Once you have copied the library ID, it must be converted from Unicode to ASCII, to do this, open PowerShell and type in the following command (Ensure to insert your previously copied string):

[uri]::UnescapeDataString("Copied String")

Creating the Configuration Profile

For me, I will use the same Configuration Profile that I used within my previous OneDrive KFM post, find all of the OneDrive applicable settings by typing in OneDrive into the search box

Configure team site libraries to sync automatically

Enable the Configure team site libraries to sync automatically settings, insert a name for your library so it’s easily identified and paste in the library ID from earlier after converting to ACSII (Take notice of the description)

Require users to confirm large delete operations

This isn’t required to sync document libs, but I would recommend enabling this policy to avoid any accidental deletion of data

Convert synced team site files to online-only files

Just like above, this setting isn’t required but is recommended, essentially expending Files-On-Demand technology to sync’d libraries

That’s it for the Configuration Profile, deploy this to your test users before deploying to production.

Decreasing the 8-Hour delay

There is a registry key that decreases the delay for end-users to see their administratively assigned libraries via the OneDrive sync client, however, this key does get removed upon every reboot, I will show you how you can use the power of Proactive Remediations via Microsoft Intune to set detect if this registry key exists and if not, create it, on a recurring schedule

Creating the Proactive Remediation profile

Navigate to Reports, Endpoint Analytics and then to Proactive Remediations; Click Create Script Package

Give an appropriate name and description (be more descriptive then me!)

Now it’s time to upload the scripts, for the detection script, copy and paste the below PowerShell code

$Path = "HKCU:\SOFTWARE\Microsoft\OneDrive\Accounts\Business1"
$Name = "TimerAutoMount"
$Type = "QWORD"
$Value = 1

Try {
    $Registry = Get-ItemProperty -Path $Path -Name $Name -ErrorAction Stop | Select-Object -ExpandProperty $Name
    If ($Registry -eq $Value){
        Write-Output "Compliant"
        Exit 0
    Write-Warning "Not Compliant"
    Exit 1
Catch {
    Write-Warning "Not Compliant"
    Exit 1

For the remediation script, copy and paste the below PowerShell code

$Path = "HKCU:\SOFTWARE\Microsoft\OneDrive\Accounts\Business1"
$Name = "TimerAutoMount"
$Type = "QWORD"
$Value = 1

Set-ItemProperty -Path $Path -Name $Name -Type $Type -Value $Value 

Ensure that the Run this script using the logged-on credentials is set to Yes and the Run script in 64-bit Powershell setting to Yes. The Settings should look like so:

Finally, set a schedule and deploy the script package to the same users or devices as you did for your Configuration Profile, I have set the schedule to run every 1 hour

Testing the results

The Sales and Marketing document library is syncing with files-on-demand set successfully

Confirmation within the OneDrive client too

Confirmation of the Proactive Remediation script doing it’s thing

Bonus Tip: Use Storage Sense to clean-up unused OneDrive data

Use Storage Sense to convert OneDrive offline files back to online on a schedule to ensure that disk space is constantly optimised, I have blogged on how to set up Storage Sense via Intune here.


Until next time!

One thought on “MEM – Automatic Syncing of OneDrive Shared Libs via Intune

  • Hi.
    How would you do this one shared devices? Have a small company but have 8 users sharing 4 computers.
    I see you have used the device policy on this articel.


Comments are closed.