Windows 10 cleanup with powershell

Raimondi, Anthony (Cognizant) 116 Reputation points
2021-04-22T20:00:35.797+00:00

Hi Guys

Do you have any good PowerShell scripts to cleanup Windows 10 harddrives? I try the cleanmgr but no matter what I do it doesn't clean the "Windows Update Cleanup" option. I need to create a script that I can run on VDIs when they get under 10 GB

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,446 questions
0 comments No comments
{count} votes

Accepted answer
  1. MotoX80 32,566 Reputation points
    2021-04-22T23:18:33.307+00:00

    How about a DISM cleanup?

    Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase
    

2 additional answers

Sort by: Most helpful
  1. Andreas Baumgarten 103K Reputation points MVP
    2021-04-22T21:19:10.127+00:00

    Hi @Raimondi, Anthony (Cognizant) ,

    maybe this help:
    https://www.jaapbrasser.com/diskcleanup-remove-previous-windows-versions-powershell-module/

    ----------

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten


  2. Ian Xue (Shanghai Wicresoft Co., Ltd.) 33,456 Reputation points Microsoft Vendor
    2021-04-23T02:24:26.88+00:00

    Hi,

    Does this help?

    https://github.com/hematic/Server-OS-Drive-Cleanup-Script/

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.