Recovering Wasted Hard Drive Space

by Jul 11, 2022

When software receives updates, it often does not clean up previous updates that are no longer required. These deprecated “patch files” accumulate in the folder c:\windows\installer as numerous *.msp files. Since you don’t know which of these *.msp files are still needed, and which can safely be deleted, it’s not easy to recover space. Unless you own Administrator privileges (which you need to fiddle with data stored in the Windows folder) and use PowerShell.

Simply download this module (requires Administrator privilege):

Install-Module -Name MSIPatches

Next, launch a PowerShell console with full Administrator privilege, and investigate the recoverable space like this:

PS> Get-MsiPatch

TotalPatchCount     : 19
TotalPatchSize      : 0,96 GB
InstalledPatchCount : 5
InstalledPatchSize  : 0,32 GB
OrphanedPatchCount  : 14
OrphanedPatchSize   : 3,64 GB  

The “Orphaned Patch Size” can be any number between 0 and many gigabytes. On one system I recovered 45GB of orphaned patches due to Office 2016 being installed (which apparently does not clean up replaced updates).

To actually clean up unnecessary patches, use this line (Administrator privilege needed):

Get-OrphanedPatch | Move-OrphanedPatch -Destination C:\Backup

This way, you can “quarantine” patch files in a safe place for a while. Don’t forget to empty the destination folder at some point in time, though. Alternately, you can of course delete orphaned patches right away. Whatever you do, though, do it on your own risk.

Twitter This Tip! ReTweet this Tip!