

To automatically cleanup the system drive on workstations with Windows 10, you can create a simple scheduled task with the following PowerShell code: If you need to configure automatic disk cleanup task on computers (or servers) in an Active Directory domain, you just need to export this registry key and deploy it on computers through the GPO. To start the drive cleanup task with the selected parameters, run the command:

For each option you select, a DWORD parameter is created with the name StateFlags0011 ( 0011 is the number you specified in the sageset parameter). This registry section lists all the Windows components that can be cleaned using the Disk Cleanup tool.

These settings are saved to the registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches. In the window that opens, select the components and files that you want to automatically cleanup (I selected all the options). Using the /sageset:xx and /sagerun:xx options, you can create and run a customized set of cleanup options.įor example, run the command: cleanmgr /sageset: 11. Your C:\ volume now has 10000 Mb of free space remaining. You have successfully resolved the low disk space condition. The cleanmgr /VERYLOWDISK command performs automatic drive cleanup (without showing GUI), and after the end it displays information about the actions performed and available free space. The cleanmgr /LOWDISK command runs the Disk Cleanup GUI with the already selected cleaning options.
