0

Problem:

A lot of older workstations on our networks are running out of hard disk space and I am looking for ways to stream-line the process of cleaning up some space. I understand I can use Disk Clean-up to do this but that requires logging on and running it manually, which can take some time for the amount of workstations we have in our environment.

Solutions I have tried:

I have already setup GPOs for Storage Sense to remove temporary files, downloads etc. but one of the larger folders is the Windows.old directory.

I found the following script using disk clean-up:

cleanmgr.exe /SAGERUN:0

But this requires me run it as the user itself and we do not have admin permissions for standard users. It also still requires user intervention to choose the folders that are deleted with disk-clean up.

Solution I am seeking:

I am looking for a script I can run via PDQ Deploy to clean-up the Windows.old directories on workstations, something I can run without any user input.

  • If you can use PowerShell Remoting, you may be able to use the solution in this question: https://serverfault.com/questions/545579/properly-remove-windows-old-on-hyper-v-server-2012-r2/545630#545630 The second answer is PowerShell only but I never tried it remotely. – Peter Hahndorf Sep 27 '23 at 17:35
  • Hi @PeterHahndorf thanks very much for the help on this one, that looks like what I need, i'll have to do some research first so I can figure out how it works. Bit of a PowerShell noob haha! Although a new problem I am finding is that only some workstations have the windows.old directory but others just show up "previous windows installations" on disk clean-up and this script wont work for those, might have to make another question here or would you recommend editing this? – PedalTech Sep 28 '23 at 11:32
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Oct 07 '23 at 07:17

1 Answers1

0

Thanks to @PeterHahndorf for the solution for removing the Windows.old folder. I also needed to be able to remove "previous windows installations" and found a thread on StackOverflow which helped me resolve that problem.

All the details I needed for using cleanmgr remotely were found in stack overflow in thread: Stack Overflow Cleanmgr Script Thread