The script can be found here.
Have you ever tried to clean up old or unused drivers in ConfigMgr and quickly became overwhelmed? It can become pretty hard to determine what drivers are truly not in use since if you attempt to import drivers that already exist, which is pretty common, you can quickly run into drivers that are in several driver packages and driver categories which can make for a challenging puzzle to unravel. Or at least it can be pretty time consuming. Unfortunately it is not as easy as simply deleting driver packages for unused hardware models.
“In Use” Drivers
So, how do we determine what drivers are actually no in use? Let me first define what “in use” means as far as drivers in ConfigMgr are concerned. If any of these conditions are true a driver is consider “in use”:
- The driver is in a Driver Package that is referenced by a Apply Drivers step of a task sequence.
- The driver is in a Driver Category that is referenced by an Auto Apply Drivers step of the task sequence.
- The driver is imported into existing boot media.
There is a caveat if you are using an auto apply drivers step utilizing all available drivers as your primary method of deploying drivers during OSD this script probably isn’t of too much use to you and will generate a warning during execution that can be ignored if so desired. There is really no way to logically determine which drivers are not in use if they are applied in this manner since you are technically using them all. The script will still run and report back unused drivers, it just can’t be trusted. If you are using an auto apply drivers step but scoping it to particular categories, this script will work just fine.
Sometimes it is just tempting to delete the driver source files and neglect the driver content ConfigMgr. This could be done to free up space on a site server for example. This is bad idea. Don’t do this. You have to delete the drivers from the console first before deleting the source. Trust me.
- Windows Management Framework (PowerShell) 5.0 – I use custom classes, because they are awesome.
- The ConfigurationManager PowerShell module. This is available anywhere the ConfigMgr console is installed.
Before using this script it is highly recommended to clean and/or delete any legacy task sequences. At the very least remove any apply drivers steps from existing task sequences you know are not being used.
- This script can take a while to run depending on your environment. (45+ minutes)
- This heavily utilizes PowerShell verbose output and creates a very detailed transcript file.
- An HTML report will be created when the HtmlReport parameter is provided. It defaults to UnusedDrivers.html.
- This script makes use of the “WhatIf”; functionality of PowerShell. Use this if you want to report on missing drivers without deleting them.
Discover what drivers are not in use but do not delete them. (WhatIf)
.\Remove-FBInactiveDrivers.ps1 -SiteCode "XXX" -SiteServer "CM01.CM.LAB" -HTMLReport "DriverUsageReport.html" -IgnoreWarnings -WhatIf -Verbose
Delete unused drivers ignore warnings for auto apply all drivers steps.
.\Remove-FBInactiveDrivers.ps1 -SiteCode "XXX" -SiteServer "CM01.CM.LAB" -HTMLReport "DriverUsageReport.html" -IgnoreWarnings -Verbose
Delete unused drivers with warnings when auto apply all drivers steps are found.
.\Remove-FBInactiveDrivers.ps1 -SiteCode "XXX" -SiteServer "CM01.CM.LAB" -HTMLReport "DriverUsageReport.html" -Verbose</pre>