Cleaning Week: Finding Fat Log File Backups

by May 30, 2016

When you run a Windows box for a couple of months or even years, a lot of disk space can be wasted by backed up log files that are not needed. So if your hard drive runs full, you may want to check how many of these log files you have, and how much space they occupy:

$path = "$env:windir\logs\cbs\"

$space = Get-ChildItem -Path $path -Filter cbspersist*.cab -File | 
  Measure-Object -Property Length -Sum |
  Select-Object -Property Count, Sum

'{0} backed up log files eat up {0:n1} MB' -f $space.Count, ($space.Sum/1MB)

You may see only a couple of files with just a couple of megabyte, or dozens of files occupying gigabytes of valuable disk space. In any case, the CAB files found by this script can safely be removed if you do not need the information for forensics or support.

Twitter This Tip! ReTweet this Tip!