- FSLogix VHDX compaction: Resize virtual disks - Thu, Dec 1 2022
- Sysinternals Process Monitor: Real-time file system, registry, and process monitoring - Fri, Oct 28 2022
- Custom error message for access denied - Tue, Sep 27 2022
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.
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."
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.
The first policy object should simply be set to Enabled to activate Storage Sense.
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
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.
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.
"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.
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, 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 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:
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.
The Downloads folder looked like this prior to cleanup:
After cleanup has run, it is completely emptied and the disk space is reclaimed.
It was similar for the Recycle Bin. Here it is prior to Storage Sense running:
And post-cleanup, it is completely emptied.
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:
After the Storage Sense threshold expires, we can see that these files have "dehydrated" back to the cloud storage location.
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.
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.