AliAlghamdi AliAlghamdi - 1 year ago 331
PowerShell Question

Automating cleanmgr.exe silently using PowerShell

I've been working on a script that is supposed to run cleanmgr.exe silently when disk C: is less than a 1gb, it's all working well, but one thing I couldn't achieve...

I want to run cleanmgr.exe silently fully! I don't wanna see anything from the disk cleanup gui not even a screen that says done.

using sageset and sagerun made it automated yes, but it still shows the process.

Here's my code (I know it has some issues regarding few things, but I'm focusing on the silent execution here, thanks!):

if ($freeSpace -le $lowSpace)
cleanmgr.exe /sagerun:10
defrag C:

echo "sorry!"

Answer Source

If you navigate to C:\windows\system32\cleanmgr.exe /? in the command prompt you will see the switches for the exe. Unfortunately, it looks like there are no silent switches for this utility.

enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download