Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / PowerShell / Remove Old and Useless Drivers from the Windows Driver Store

August 24, 2022 PowerShellWindows 10Windows 11Windows Server 2019

Remove Old and Useless Drivers from the Windows Driver Store

When you install or update device drivers in Windows, older versions of the drivers remain on the system drive. This allows the user to roll back to a previous driver version if the new driver is unstable. However, Windows doesn’t automatically remove old and useless versions of drivers, so over time, the amount of space occupied by drivers on the system drive becomes quite large. In this article, we will look at several ways to remove obsolete and old versions of drivers (duplicates) in Windows using built-in and third-party tools.

Contents:
  • How to Find and Remove Old Drivers in Windows with PowerShell?
  • Delete Old Drivers in Windows using Disk Cleanup Tool
  • Removing Unused Drivers with DevManView

Windows stores all driver files in its driver repository (Driver Store) located in the %WINDIR%\System32\DriverStore\FileRepository.

You can get the driver store directory size with PowerShell ( "{0:N2} GB" -f ((gci –force $Env:windir\System32\DriverStore\FileRepository –Recurse -ErrorAction SilentlyContinue| measure Length -s).sum / 1Gb) ) or graphic tools. On my home Windows laptop, the FileRepository directory takes up about 11 GB of disk space and contains over 5,000 files. There are over 20 different versions of the NVIDIA video graphic driver stored in this directory.

large size of folder DriverStore

Important!

  • Never delete any files from DriverStore manually;
  • It is highly recommended to create a system restore point before cleaning device drivers (Checkpoint-Computer -Description "BeforeDriversDelete") or back up your Windows system image;
  • After cleaning the driver store, you will have to download and install drivers when you connect new devices.

How to Find and Remove Old Drivers in Windows with PowerShell?

Let’s look at how to find out and remove old versions of drivers in Windows. You can display a complete list of installed drivers using PowerShell and WMI (CIM) class Win32_PnPSignedDriver:

Get-WmiObject Win32_PnPSignedDriver| select DeviceName, DeviceClass,Manufacturer, DriverVersion, DriverDate,InfName|Out-GridView

In my example, I got an Out-GridView table with a list of drivers in the Windows repository in the format: device name, device class, manufacturer, driver version, installation date, driver inf file name (oemXXX.inf).

get list of device driver installed in windows driver store

You can get a list of third-party drivers installed on Windows using the Get-WindowsDriver cmdlet:

Get-WindowsDriver –Online| select Driver, ClassName, BootCritical, ProviderName, Date, Version, OriginalFileName|Out-GridView

You can remove any of the installed drivers using the pnputil CLI tool:

pnputil.exe /remove-device oemxxx.inf

Note. In some cases, only remove the driver with the /force (-f) switch:
pnputil /remove-device oemxxx.inf /force

Look in the table for drivers that have multiple versions and remove all older versions of the driver (except the latest one) using pnputil.exe.

Be especially careful with drivers that are critical to the Windows boot process (BootCritical=True).

You can also export the list of installed drivers to a text file and then import it into Excel:

dism /online /get-drivers /format:table > c:\tmp\drivers.txt

Delete all unnecessary data in the table and leave only the following columns: the driver file in the system (oemXXX.inf), the name of the source INF file, device class, manufacturer, installation date, and driver version. Sort this table by column B (containing the name of the original INF file) and column F (driver installation date). Among the drivers with the same name, mark for removal all driver versions except the last one. In my case, you can see that most old drivers are referred to the NVIDIA video adapter.

To make it more convenient, let’s create an additional column with the command to uninstall each driver using the simple formula: =CONCATENATE("pnputil.exe -d ";A21)

analyze old drivers list in excel

Copy and run the pnputil commands in the command prompt or a BAT file.

pnputil Driver package deleted successfully

pnputil.exe –d oem9.inf
Microsoft PnP Utility
Driver package deleted successfully

In my case, I deleted about 40 old versions of drivers in Windows and cleared about 8 GB of space (mostly due to removing NVIDIA video card drivers).

You can use the RemoveOldDuplicateDrivers.ps1 PowerShell script to automatically find device drivers that have multiple driver versions (duplicates) installed. (https://github.com/maxbakhub/winposh/blob/main/WindowsDesktopManagement/RemoveOldDuplicateDrivers.ps1 ).

find unused and duplicate drivers with powershell script

The script will display a list of old driver versions that can be removed because newer versions are installed. The lines with automatic removal actions of found drivers are commented out in the script by default.

Delete Old Drivers in Windows using Disk Cleanup Tool

In current versions of Windows 10 and 11, you can use the built-in cleanmgr.exe (Disk Cleanup tool) to clean up the Driverstore Filerepository folder.

Note. You can backup all third-party device drivers by exporting them to a separate folder with the Export-WindowsDriver PowerShell cmdlet.
  1. Run the Disk Cleanup: Win+R -> cleanmgr;
  2. Select the system drive;disk cleanup drive c
  3. Click Clean up system files; Clean up system files
  4. Check Device driver packages in the list;Cleanup Device driver packages - Windows 10
  5. Click OK;
  6. This cleanup task will remove all previous versions of drivers installed through Windows Update or manually. Only the latest version for each of the drivers will remain in Windows DriverStore. However, you should be aware that the “Roll back driver” button in the Driver Properties tab of Device Manager will become inactive. unable to rollback device driver in windows device manager
    The cleanmgr task only removes duplicate versions of drivers. Unused device drivers should be removed manually.

Removing Unused Drivers with DevManView

You can use a small free tool DevManView (by NirSoft) to view and manage the list of installed drivers in the Windows Driver Store.

DevManView is an excellent alternative to the standard Windows Device Manager MMC snap-in and allows you to present a list of drivers installed on your computer as a flat list (table).

  1. Download and run the DevManView tool;
  2. Enable the following items in the Options menu: Mark Connected Devices and Show Non-Plug and Play Drivers;
  3. Sort the table by the Connected column. This will allow you to see which devices are currently connected and which are not;
  4. We recommend you disable the selected device drivers first (Disable Selected Devices –> F6) and only after restarting the computer, remove the drivers using the Uninstall Selected Devices option.devmanview tool allows to remove unused drivers in windows

13 comments
7
Facebook Twitter Google + Pinterest
previous post
How to Remove (Demote) a Domain Controller in Active Directory
next post
Using Attribute Editor in Active Directory Users and Computers

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

October 15, 2023

How to Query and Change Teams User Presence...

October 8, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

13 comments

Marko June 13, 2018 - 8:16 pm

great article!!! thanks a million!

Reply
KV January 31, 2019 - 4:30 pm

How did you import from the txt file to excel? Copy and paste just leaves all the info in the first column of cells

Reply
admin February 8, 2019 - 5:19 pm

You shold use “Tab” as a delimeter when importing a txt file to Excel

Reply
Emily Bowman January 26, 2020 - 7:06 am

Note that you cannot copy-paste between regular and administrator windows if UAC is active. You have to retype anyway or use the filesystem to transfer commands (like make a batch file and then run it from admin).

Nvidia and Intel are so aggravating with their massive drivers that never clean up after themselves. Lots of other places they suck up space around the system, too, like the shader cache.

Reply
John Schindler May 1, 2020 - 5:10 pm

Nice, but the file I want to remove “is not an installed OEM inf”.

Reply
Emily Bowman May 1, 2020 - 7:38 pm

The best way to remove a built-in windows component is with NTLite and reinstall. Once installed, there’s not much you can do.

Reply
Ojo October 25, 2021 - 6:05 pm

Great article. I found so many bad recipes. This was trivial and clearly the correct way.

Reply
Phil September 17, 2022 - 3:59 am

Great except the actual removal command should be:
pnputil /delete-driver oemXXX.inf

Reply
Steve Sybesma March 27, 2023 - 8:25 am

I installed an INF manually by right clicking the INF and clicking Install because the driver wouldn’t install the normal way and it turns out the device is completely incompatible with the driver as there was no change in Device Manager at all.
So in other words, I installed an orphaned driver.
Since the driver does not show in DevManView or when using CleanMgr.exe and checking Device driver packages (0 bytes) I assume this is an exception to your rule and it’s ok to directly delete the two files that have the driver name in them.

Reply
Steve Sybesma March 27, 2023 - 8:27 am

The filename of the driver is android_winusb.inf so it can’t be removed with the pnputil command either.

Reply
Steve Sybesma March 27, 2023 - 8:34 am

I may have a resolution. OEM113.inf is tied to that filename above in the registry. So pnputil may be useful after all. I guess Windows renames the driver to that format because that is not the file I installed. I guess it’s an internal name/external name thing.

Reply
Steve Sybesma March 27, 2023 - 8:42 am

I forgot to add…that I found it with 100% certainty in the registry because the filename in the driver store includes the long guid number or whatever you call it and that appears in the registry entry and that is tied to OEM113.inf
Just learned something today on how this works and how to properly uninstall an INF file.

Reply
Steve Sybesma March 27, 2023 - 8:46 am

Final update: the command “pnputil /delete-driver oem113.inf” worked like a charm!!!
I had my Everything window open showing the two locations of the files in the driver store repository and they disappeared!!!
PERFECT!!!!!!!

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Fix: Remote Desktop Licensing Mode is not Configured
  • Manage Windows Updates with PSWindowsUpdate PowerShell Module
  • Configuring Port Forwarding in Windows
  • Start Menu or Taskbar Search Not Working in Windows 10/11
  • How to Install Remote Server Administration Tools (RSAT) on Windows
  • How to Delete Old User Profiles in Windows
  • Get-ADUser: Find Active Directory User Info with PowerShell
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top