Windows drivers are not something a regular PC user cares about. One might start thinking about drivers only when games stop working (or working poorly) or when they need to clean drive C and reclaim storage. Once everything possible is removed, users start experimenting with the Driver Store folder, which is responsible for storing old and unused Windows drivers. They do that for a reason—the folder often consumes staggering amounts of space, sometimes beyond tens of gigabytes.
This article will show you how to remove old unused drivers from the Driver Store folder using PowerShell and other methods. It applies to Windows 10 and 11.
You can find the Driver Store folder in C:\Windows\System32\DriverStore\FileRepository. Navigating to the directory reveals an impressively large list of folders with hard-to-read names. Those are your old drivers Windows no longer uses. However, you cannot just Shift + Delete them—Windows has a dedicated procedure for deleting unused drivers from the Driver Store folder.
Important. Some blogs recommend changing the owner of the Driver Store folder and deleting it manually. Do not do that! A script for Power Shell and a free third-party app we will mention below are much better, safer, and more convenient options for deleting old unused drivers from your computer.
Remove Old Drivers from Driver Store using PowerShell
Instead of Shift+Deleting the Driver Store folder, use a Power Shell script. It removes all duplicate drivers and leaves only the latest versions you might need when troubleshooting.
Consider the following before you delete old Windows drivers using Power Shell:
- Update Power Shell to Windows Management Framework 4 or newer.
- Create a system restore point in case something goes wrong. It is an excellent practice to create restore points whenever you modify your system settings, experiment with the registry, work with drivers, etc. You can make a restore point by running PowerShell as Administrator and executing the following command:
Checkpoint-Computer -Description “PointBeforeDeleteUnusedDrivers”
After that, verify your restore point with the Get-ComputerRestorePoint command.
Now you can start deleting old drivers. Run the following command to get the list of all third-party drivers: dism /online /get-drivers. After that, you need to parse the output in Power Shell, select driver duplicates and sort them by date. You can also exclude the most recent drivers from the results.
Note. Check our guide on how to run PowerShell script on Remote Computer.
Here is the script that lets you remove old unused drivers from Driver Store using Power Shell.
Tip. To display only the unused drivers, type Invoke-Expression and add the # character before the command Invoke-Expression -Command “pnputil.exe -d $Name.
$dismOut = dism /online /get-drivers $Lines = $dismOut | select -Skip 10 $Operation = "theName" $Drivers = @() foreach ( $Line in $Lines ) { $tmp = $Line $txt = $($tmp.Split( ':' ))[1] switch ($Operation) { 'theName' { $Name = $txt $Operation = 'theFileName' break } 'theFileName' { $FileName = $txt.Trim() $Operation = 'theEntr' break } 'theEntr' { $Entr = $txt.Trim() $Operation = 'theClassName' break } 'theClassName' { $ClassName = $txt.Trim() $Operation = 'theVendor' break } 'theVendor' { $Vendor = $txt.Trim() $Operation = 'theDate' break } 'theDate' { # change the date format for easy sorting $tmp = $txt.split( '.' ) $txt = "$($tmp[2]).$($tmp[1]).$($tmp[0].Trim())" $Date = $txt $Operation = 'theVersion' break } 'theVersion' { $Version = $txt.Trim() $Operation = 'theNull' $params = [ordered]@{ 'FileName' = $FileName 'Vendor' = $Vendor 'Date' = $Date 'Name' = $Name 'ClassName' = $ClassName 'Version' = $Version 'Entr' = $Entr } $obj = New-Object -TypeName PSObject -Property $params $Drivers += $obj break } 'theNull' { $Operation = 'theName' break } } } Write-Host "All installed third-party drivers" $Drivers | sort Filename | ft Write-Host "Different versions" $last = '' $NotUnique = @() foreach ( $Dr in $($Drivers | sort Filename) ) { if ($Dr.FileName -eq $last ) { $NotUnique += $Dr } $last = $Dr.FileName } $NotUnique | sort FileName | ft Write-Host "Outdated drivers" $list = $NotUnique | select -ExpandProperty FileName -Unique $ToDel = @() foreach ( $Dr in $list ) { Write-Host "duplicate found" -ForegroundColor Yellow $sel = $Drivers | where { $_.FileName -eq $Dr } | sort date -Descending | select -Skip 1 $sel | ft $ToDel += $sel } Write-Host "Drivers to remove" -ForegroundColor Red $ToDel | ft # removing old drivers foreach ( $item in $ToDel ) { $Name = $($item.Name).Trim() Write-Host "deleting $Name" -ForegroundColor Yellow Write-Host "pnputil.exe -d $Name" -ForegroundColor Yellow Invoke-Expression -Command "pnputil.exe -d $Name" }
Copy the script and save it to a file called drv_cleanup.ps1. You can paste the script in Notepad, save the file, and then rename its txt extension to ps1. Place the file in C:\Ps. Now open Windows Terminal or Power Shell as Administrator and allow executing unsigned scripts with the following command: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass.
Note. Check our guide about what to do when you are unable to set printer as default in Windows.
Run the script stored in C:\Ps with the C:\Ps\drv_cleanup.ps1 command. Wait for the system to complete the procedure. After that, restart your computer.
Delete Old Unused Drivers from Driver Store using DriverStoreExplorer
We understand that Power Shell might not be the most user-friendly way to delete old unused drivers from Driver Store. Those not comfortable with commands and scripts can try using the DriverStoreExplorer app. It has a much more user-friendly user interface that lets you browse all unused drivers, sort them by categories, check their versions, driver date, size, etc. It is an excellent app, and it is also completely free.
- Download DriverStoreExplorer from Github.
- Extract the archive in a convenient folder.
- Open the Rapr file.
- Wait for the app to analyze your Driver Store folder. Note that the process might take a while, depending on how big the folder is.
- Click Select Old Drivers.
- The app will select old and unused drivers you can safely delete.
- Click Delete Drivers. Do not delete drivers the option Select Old Drivers has not checked. That might result in the app deleting the drivers that are currently in use.
Now you can go to the C:\Windows\System32\DriverStore\FileRepository folder and see how much space the utility has reclaimed by deleting old unused drivers from Driver Repository.
That is how you remove old unused drivers from Driver Repository using Power Shell and third-party applications.
1 comment
There is a bug: months and dates have to be formated to add leading zeros.
So, had to replace the date function like this:
‘theDate’ { # changed the way the strings are formated so month 03 comes before 12 (was 12 before 3)
$tmp = $txt.split( ‘/’ )
$txt = “$(‘{0:d4}’ -f [int]$tmp[2]).$(‘{0:d2}’ -f [int]$tmp[0]).$(‘{0:d2}’ -f [int]$tmp[1].Trim())”
$Date = $txt
$Operation = ‘theVersion’
break
}