Microsoft's OneDrive application is making large inroads into enterprises as the Enterprise File Share and Sync (EFSS) tool of choice. While it's easy to get up and running on personal devices, managing the OneDrive experience for users at any sort of scale can be challenging, particularly where users have limited storage or if they operate in Remote Desktop Session Host or VDI environments. Another option Microsoft gives you to help with these problems is a feature called Storage Sense.
Avatar

What is Windows Storage Sense?

Storage Sense is relatively new, having arrived in the 1809 version of Windows 10. It is primarily focused on replacing the Disk Cleanup Wizard, which is being deprecated, but is currently retained for compatibility purposes (Storage Sense is effectively a superset of the Disk Cleanup Wizard). However, in enterprise environments where users generally have little or no access to the local disks, dealing with the OneDrive cache becomes Storage Sense's most pertinent application.

Storage Sense with OneDrive should be used in conjunction with Files On-Demand, as this allows the option to "dehydrate" unused files back into the cloud storage rather than keep them on the local device. Files On-Demand requires Windows 10 version 1709 or higher, or Windows Server 2019.

Configuring Storage Sense

First, the devices on which you wish to configure Storage Sense obviously need to have the OneDrive Sync Client installed and Files On-Demand turned on if you wish to take advantage of the cloud content management. You can obviously use the other features of Storage Sense without OneDrive to save disk space, but the specific OneDrive-related settings need these prerequisites.

OneDrive Files On Demand

OneDrive Files On Demand

Storage Sense can be configured directly by the user from within the Windows user interface, but in enterprise environments, it is prudent to use Group Policy Objects to manage it. In order to manage it via GPO, you need to be on the 1903 version of Windows 10. In the first instance, we can configure it to save disk space in general, rather like the Disk Cleanup Wizard, or more advanced third-party software like CCleaner.

An annoyance about the Storage Sense GPOs, however, is that their descriptions do not particularly specify what they are referring to.

Reclaiming disk space with Storage Sense

Be aware that Storage Sense is actually turned on by default when the user device runs into what Microsoft refers to as "storage pressure."

Storage Sense default settings

Storage Sense default settings

It's not actually clear what "low disk space" means, in terms of threshold. I am willing to postulate that this possibly means 10% or lower, which is the default level at which a storage device will turn red in File Explorer.

If you wish to have more granular control over this, then you can enable Storage Sense directly through the first GPO. All the GPOs are located under Computer Configuration | Administrative Templates | System | Storage Sense.

Storage Sense list of available GPOs

Storage Sense list of available GPOs

The first policy object should simply be set to Enabled to activate Storage Sense.

Storage Sense enabled

Storage Sense enabled

The second enables you to allow Storage Sense to remove temporary files. According to the Microsoft documentation, "temporary files" covers:

  • Temporary setup files
  • Old indexed content
  • System cache files
  • Internet cache files
  • Device Driver packages
  • System downloaded program files
  • Dated system log files
  • System error memory dump files
  • System error minidump files
  • Temporary system files
  • Dated Windows update temporary files
Storage Sense temporary files cleanup

Storage Sense temporary files cleanup

The next setting is the "Configure Storage Sense Cloud Content dehydration threshold," and this one is key to the management of the OneDrive cache.

"Dehydration threshold" means that when the file has not been opened for the amount of time specified in the GPO, the file will be removed from the local cache and sent back to cloud storage only. If you set this to 0, content will never be dehydrated. You can choose a threshold of up to one year (365 days). As mentioned, this is crucial for OneDrive management as you can reclaim disk space that is being used by the OneDrive cache. If the user needs to access a file again in the future, they can simply re-download it from the cloud storage location.

"Cloud-backed content" in this context refers specifically only to OneDrive and the OneDrive Sync Client. Other cloud storage, such as DropBox, is not supported, and it is unclear if it ever will be. Also, other Microsoft content that is potentially cloud-synchronized (such as OneNote notebooks) is not currently covered by Storage Sense.

Storage Sense dehydration threshold

Storage Sense dehydration threshold

The next setting is "Configure Storage Sense Downloads cleanup threshold" (although it is erroneously called "Storage Storage" in the current ADMX files available from Microsoft). This simply applies the same minimum age threshold to the user's Downloads folder before removing files from there. You may need to use this setting with care, as users have been known to use the Downloads folder as a key storage area. However, I always encourage treating the Downloads folder as a scratch area so I feel comfortable setting a low threshold for deletion.

Storage Sense Downloads cleanup threshold

Storage Sense Downloads cleanup threshold

"Configure Storage Sense Recycle Bin cleanup threshold" works in exactly the same way as the setting for the Downloads folder but just applies to the Recycle Bin instead. Again, it is important to understand user behavior for this configuration item because some users may require their deleted files to be recoverable.

Storage Sense Recycle Bin cleanup threshold

Storage Sense Recycle Bin cleanup threshold

Finally, there is "Configure Storage Sense cadence." This setting allows you to control how often Storage Sense will run. You can run during "low disk space" only (but again, without any indication of what actually constitutes low disk space), or on a monthly, weekly, or daily schedule. The choice of this setting depends on your environment, but for RDSH users with potentially large OneDrive caches, I found a daily routine to be useful.

Storage Sense cadence

Storage Sense cadence

Storage Sense, once configured, works via a scheduled task. Again, it is unclear whether there is any offset for this task or whether it runs on a defined schedule if you configure it as daily, weekly, or monthly.

Storage Sense Scheduled Task

Storage Sense Scheduled Task

Storage Sense in use

Once configured, you should be able to observe the automatic cleanup and rehydration of system files and OneDrive data.

We configured a Windows 10 2004 device with Office365 and OneDrive, synchronized the user data, downloaded a number of files, and then set the GPOs to clean up after one day.

The temporary folder for the user looked like this prior to cleanup:

Temp folder before cleanup

Temp folder before cleanup

After Storage Sense has run, it looks like this. Not all the files older than one day (our threshold) have been removed, but this is because some temporary files are often locked in use. However, cleanup has been performed and less disk space is being used.

Temp folder after cleanup

Temp folder after cleanup

The Downloads folder looked like this prior to cleanup:

Downloads folder before cleanup

Downloads folder before cleanup

After cleanup has run, it is completely emptied and the disk space is reclaimed.

Downloads folder after cleanup

Downloads folder after cleanup

It was similar for the Recycle Bin. Here it is prior to Storage Sense running:

Recycle Bin prior to cleanup

Recycle Bin prior to cleanup

And post-cleanup, it is completely emptied.

Recycle Bin after cleanup

Recycle Bin after cleanup

And for the most pertinent part (if you're looking to manage the OneDrive storage usage), the OneDrive folder. Here is the user's OneDrive folder on the local device prior to Storage Sense running, showing the files the user has downloaded to the cache:

OneDrive prior to cleanup

OneDrive prior to cleanup

After the Storage Sense threshold expires, we can see that these files have "dehydrated" back to the cloud storage location.

OneDrive after cleanup

OneDrive after cleanup

So in summary, we can now create an automated disk space reclamation schedule for our users that also clears out the OneDrive cache. This cache can become a real bone of contention, particularly in RDSH environments, so it is good to have this functionality available.

Caveats

One annoying thing about Storage Sense (and for a lot of newer Microsoft GPOs) is that these settings are computer config items. It would be useful to be able to configure different Storage Sense settings for different groups of users, particularly with regard to the Downloads and Recycle Bin folders, because different users use these areas in different ways.

It is also annoying that Microsoft has not documented how Storage Sense works very thoroughly. We have no idea what the threshold is for "low disk space" and we do not have much visibility or control over how the process is scheduled.

Also, if you are using a technology like Microsoft FSLogix Profile Containers to manage your user profiles and OneDrive cache, you will not reclaim the space used in the cache even if the files are "dehydrated." With FSLogix containers, space is never reclaimed once committed unless you physically run a maintenance routine to shrink the VHD(x) once the space is freed. There are many maintenance scripts around that can be used. One of the more popular ones is from Jim Moyle.

Subscribe to 4sysops newsletter!

But overall, Storage Sense represents a step forward from the old "Disk Cleanup" feature and offers the first functionality that integrates nicely with OneDrive in this fashion. It would be nice to see it develop further to become more granular and more widely integrated, but it offers some good options for administrators struggling with storage overheads.

8 Comments
  1. Avatar
    Kid Kooijmans 3 years ago

    Hi James,

    We have “files on demand” working on a 2019 CVAD but it seems that the storage sense OneDrive dehydration is not available (at least not via GPO). Is this correct?

    Best Regards,

    Kid

    • Avatar
      Chris Marreel 3 years ago

      Hi Kid,

      Have you found a solution to use Storage Sense for OneDrive 'dehydraion'  on 2019 ?

      Thanks for you input and greetings,

        Chris Marreel

      • Avatar
        James Rankin 3 years ago

        You need to set some cryptic settings so Storage Sense can work on 2019, apologies for not checking this in the article. You're right, the GPOs don't work.

        See this article for some pointers https://stealthpuppy.com/windows-10-storage-sense-intune/

        • Avatar
          James Rankin 3 years ago

          Also, you CAN configure OneDrive dehydration as well. Simply make sure the user is signed into OneDrive, and set the 2 value in HKCU\Software\SyncEngines\Providers\OneDrive\ to turn it on, and 128 value to set the cadence (amount of days)

  2. Avatar
    Chris Marreel 3 years ago

    Hi James,

    I had already created my own powershell-script to deploy the needed registry settings in the current-user registry to activate Storage Sense and indeed there is some strange construction (you called it cryptic settings…) needed with the ID of the user and some Providerkey-string.  And we can deploy this powershell-script via a Group Policy.  This all is working (in a Full Desktop session).

    But now we notice that OneDrive-client isn't officialy supported in a Published Application- or Remote App-  (mini)-session.  And in many Citrix XenApp-setups these Published Applications are one of the most used and super handy features.  More and more of our customers (I work at a Microsoft + Citrix-partner in Belgium and we have hundreds of customer-setups on RDSH and Citrix XenApp) are looking at adopting OneDrive.  And now it is of couse very hard to tell them that the OneDrive-client isn't supported.  And then the Storage Sense function isn't also supported and even not running is such Published Application or Remote App sessions.

    At the moment we are a bit stuck.  And I'm a bit disapointed in the solutions of Microsoft.  They have nice features like the OneDrive-client, but why are they not always working as one should expect…

     

    Greetings from Belgium,

      Chris Marreel

     

    • Avatar
      James Rankin 3 years ago

      In those cases I'd just use something like CloudDriveMapper, ideally with the drive hidden and a special folder deployed in Explorer. Arguably, there's no need for any sort of local cache on a XenApp/XenDesktop environment and hence no real need for Storage Sense either.

  3. Avatar
    George James 3 years ago

    Thanks for this article James. Got me over some sticking points :).

    Chris, I did get OneDrive working with Published Apps by adding "C:\Program Files (x86)\Microsoft OneDrive\OneDrive.exe" to my OneDrive login script.

    I also had to add the following OneDrive.exe registry entry to close OneDrive.exe when the published app is closed or the session remains open as per https://support.citrix.com/article/CTX891671

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Citrix\wfshell\TWI
    Value Name:LogoffCheckSysModules
    Type:REG_SZ
    String:OneDrive.exe

Leave a reply

Your email address will not be published. Required fields are marked *

*

© 4sysops 2006 - 2023

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account