Tag Archives: Set-StorageSense

Configure Storage Sense using PowerShell

Recently the Storage Sense functionality has been added to Windows. Unfortunately there are no PowerShell commands available to manage this so I decided to write this function to be able to manage the different settings that are available in regards to Storage Sense.

There are a number of settings that can be configured in the Settings > Storage > Storage sense, settings menu. The settings that can be configured are as follows:

By clicking: Change how we free up space, the following options become available:

So in order to configure this using PowerShell I have created the Set-StorageSense function with the following parameters:

  • EnableStorageSense
  • DisableStorageSense
  • RemoveAppFiles
  • ClearRecycleBin

So if you would like to disable this functionality and not have Windows automatically clear out temporarily and otherwise obsolete files you can run the following command:

Set-StorageSense -DisableStorageSense

Alternatively the other options can also be configured, the following command Enables Storage Sense and configures all cleanup options to true while displaying verbose output:

Set-StorageSense -EnableStorageSense -RemoveAppFiles $true`
-ClearRecycleBin $true -Verbose

This would of course not be complete without being able to query this data as well, which is possible using the Get-StorageSense function:

Although I looked into manually triggering the Clean Up job, this is something that did not seem possible, I used Sysinternals Procmon to determine which command is associated with that. But even when running this as the System account it did not appear to clean anything. I will provide the execution in case it is of value for anyone else:

c:\windows\system32\svchost.exe -k localsystemnetworkrestricted -s StorSvc

Let me know if PowerShell functions like these are useful to you and if it works as expected. Do note that this functionality is only available in recent builds of Windows 10.

Links in this Article
GitHub – Get-StorageSense
GitHub – Set-StorageSense
GitHub – CustomizeWindows10 Module
PowerShellGallery – CustomizeWindows10 Module