Clean up your C: Drive

more about this script can be found at http://www.theovernightadmin.com/2013/10/cleanup-c-drive-with-windows-powershell.htmlNOTE: Download Start-Cleanup.ps1 for the 2018 version of this script. This is by far my favorite script in my arsenal of scripts, this bad boy can delete a

 
 
 
 
 
3.5 Star
(28)
25,588 times
Add to favorites
Servers
5/22/2018
E-mail Twitter del.icio.us Digg Facebook
  • can you add to clean up ccmcache folder
    1 Posts | Last post August 23, 2019
    • good script but can you also add clean up ccmcache.
      i normally go to config mgr > cache tab > and there i clear it so it normally helps me claiming over 8gb min all the times.
      
      pls can you incorporate this
  • using for remote computers
    4 Posts | Last post June 28, 2019
    • how can we use this to cleanup C drive of remote computers?
    • If the infrastructure is set up for PowerShell Remoting then you should be able to run something like:
      
      invoke-command -FilePath "\\ADDC-01\Scripts\cleanup_log.ps1" -ComputerName localhost, server01, server02, servre03
      
      Note: the file path \\ADDC-01\Scripts\cleanup_log.ps1 will have to reflect where you have saved the script and the filepath must be shared with whomever is running the script.
      
    • Hi Matthew..
      
      Nice Script ...But Could you please help here to run this script on multiple system.
    • $RemoteComputers = Get-Content "C:\temp\Textfilewithnamesofmachines.txt"
      Invoke-Command -ComputerName $RemoteComputers -FilePath C:\temp\CleanupScript.ps1
      
      Tested in Windows 7/10 Domain joined environment. Make sure you have WMI and BITS running. Would be good if you ping machines first.
      
      Cheers
      Raghu
  • Correction
    1 Posts | Last post June 28, 2019
    • Hi Mate,
      
      First of all thanks a lot for this. It worked great for me on Windows 7 domain joined machine. 
      
      One correction at 75 line, there is one back quote at the end
      
      Get-ChildItem "C:\users\*\AppData\Local\Microsoft\Windows\Temporary Internet Files\*" `
      
      Cheers
  • SCCM Cache Size
    1 Posts | Last post October 31, 2018
    • Nice script, Matthew!  However, I'm running into some difficulty regarding the SCCM cache size setting.....
      
      1.  When running this section of the script I am ending up with 0 MB cache sizes.  I'm sure this is not the intention.  I tried using a different setting (5120 MB) & removing ErrorAction & WarningAction options in hopes that would tell me something but I'm still getting 0 MB.  Any ideas? 
      
      2.  Does this script purge the cache or simply reset the size?  Purging would be useful as this can be a cause of space loss, too.
      
      By the way, the downloaded script seems to vary a great deal from what I see in the description.  Maybe you need to update it with your latest version of the script??  I'm certainly no PS guru but it would be a shame to run some code that you weren't aware of running.
      
      -Dave
      
      
  • Script Issues and It Cannot Run Silently/Remotely
    1 Posts | Last post August 15, 2018
    • Hi Matthew
      
      Firstly, thanks for creating a sharing this script. Clearly you have put some time into it.
      
      There are some issues with your script that you might be interested in resolving?
      
      For us, we want to automate the running of the script by silently executing it on remote machines when SCCM determines their disk space falls below a threshold.
      
      So your script cannot work because of the following:
      
      1) Lines 123, 135, 185 are mistakes. Probably cut and paste errors? ;)
      
      2) The script cannot be run silently, as it prompts the user if they want to check for ISO/VHD files. This seems unnecessary, surely a command line option, or simply the ability to easily comment out that section would suffice?
      
      2) CleanMgr.exe process will never complete on Windows 10 devices, as by default there are no default 'sageset' flags on Windows 10. I recommend a quick read of the following article and script which show how you can set the registry flags so you can create a sage set (and so you specify the exact actions you want to run) before running CleanMgr.
      Line 398 in this script - https://github.com/DeploymentBunny/Files/blob/master/Tools/Action-CleanupBeforeSysprep/Action-CleanupBeforeSysprep.wsf
      also https://stealthpuppy.com/cleaning-up-and-reducing-the-size-of-your-master-image
      
      Without these the CleanMgr process never closes and so the script never continues on Windows 10.
      
      Using this method, you know for certain that the SageRun number you create exists and the command will function as intended.
      
      3) Make it easier to change the log file path, C:\Temp is not ideal for everyone else in the world!
      
      Hope these comments help Matthew, let me know what you think.
      
      Regards
      
      Mike
  • Listview
    1 Posts | Last post April 02, 2017
    • Hi Matthew,
      
      Is there a way to execute this script with listview output only?
      
      I mean, execute and list the output only (without any deletions)...
      
      Regards,
      Ebo
  • Recycle Bin Section
    1 Posts | Last post January 18, 2017
    • Greetings, I have been using this script for the last year, but actually reading into the script clearly, I noticed your Empty Recycle Bin lin didn even have a script to run within that section. Was this not entered on purpose or of error? 
      
      Has this script improved/changed over the last year, as I love what this does for us, but am open to new things as well Windows now eats up disk space with.