PowerShell Script for removing the “Windows.old” folder using cleanmgr.exe command line
New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Temporary Setup Files' -PropertyType 'DWORD' -Force -Name 'StateFlags1337' -Value 0x2 New-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Previous Installations' -PropertyType 'DWORD' -Force -Name 'StateFlags1337' -Value 0x2 cleanmgr.exe /SAGERUN:1337
Great post on the syntax of “Cleanmgr.exe”
https://winaero.com/blog/cleanmgr-exe-command-line-arguments-in-windows-10/