How can I set Onedrive to auto-cleanup offline cache on Windows Server 2019

Azazel90 396 Reputation points
2021-09-01T10:05:51.967+00:00

As far as I know, it can be done by Storage Sense which is not fully functional in Windows Server 2019. However it is built in, but it won't apply GPO settings. I've been searching for a solution and found this script on github: https://github.com/kaspersmjohansen/StorageSense/blob/main/Configure-StorageSense.ps1 (credits to the author of the code)

Now I've applied this script as a logon script via GPO in my domain and I can see the results in regedit. The srcipt sets the registry records exactly as it's meant to but it won't have any effect on the system. I've tried to set the auto-delete of onedrive offline cache to 1 day so it should remove the offline copies of onedrive files every single dasy. I waited 48 hours just to make sure and also logged in and out then checked if the GPO has been applied to my test user account and it has. Any suggestions on how to solve this? We are trying to implement Onedrive in an RDS environment so we need to make sure the offline cache is gonna be deleted every now and then so that users can't eat up all their disk space. Built-in onedrive GPO settings work properly but this one with the sript setting the registry values won't have any effect.

Windows for business | Windows Client for IT Pros | User experience | Remote desktop services and terminal services
Microsoft 365 and Office | OneDrive | For business | Windows
Windows for business | Windows Client for IT Pros | User experience | Other
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,931 Reputation points
    2021-09-01T14:37:37.897+00:00

    Hello,

    Thank you for your question.

    I would like to suggest you to check for new User profile and see if GPO have been applied and storage sense works for that new user profile.
    also , please check that GPO result using below cmd

    gpresult /h C:\temp\gpresult.htm

    Additionally is this script work if you run it manually and Offline cache cleaned up.

    Please have a look on below Microsoft article for One Drive GPO and check for Use OneDrive Files On-Demand settings.

    https://learn.microsoft.com/en-us/onedrive/use-group-policy

    If the reply was helpful, please don’t forget to upvote or accept as answer.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.