Deleting 30000 drivers and re-importing 162 Driver packs

We started noticing our driver packages were really big and consuming a lot of time during OSD. This was due to the bug mentioned in KB3084586

The longer we left it the worse it got!

What happens is any drivers added to the database before the fix will still have issues being re-imported unless they have been deleted before the re-import. So the solution for us was to get rid of every driver then add them back.

There are a few scripts online to import drivers and I merged some together to fit our environment however during testing they would often stop working after a few imports as if powershell wasn't getting a response back. To work around this I used a powershell function called start-job with a timeout so it would move to the next import if it had no response.

Script can be downloaded from Github here


To delete all drivers first it's just one line

This took 6 hours in my environment..

OPTIONAL: To set driver packages to high priority run this script
modify cd PS1:)

Then modify the sitecode var in the main script (ImportDriver.ps1)

for each driver package you run the powershell script with parameters

It also creates packages and categories if they don't exist. Also updates the distribution points.

This took 3 days in my environment... If I did this again, I would have imported the WIN7 drivers first as this change impacted 1 business day of imaging.

Update: I've noticed the Intel HD Graphics 5xx drivers must have timed out during the import, we have now imported them manually.



  1. I had to change a few things in the script for "MECM 2002"

    $Sitecode doesn't work - changed to - cd "$((Get-PSDrive -PSProvider CMSite).Name):"

    Import-Module was specific to a client folder, this finds your install whereever it is - Import-Module (Join-Path $(Split-Path $env:SMS_ADMIN_UI_PATH) ConfigurationManager.psd1)

    Got it up and running in an hour or too troubleshooting it. The PS script is slow, but is more thorough, at least you don't get what the GUI throws: "All drivers are imported successfully. Drivers cannot be added to some driver package(s).", with package folder empty or filled with only a few items, even though it say all drivers were imported (to where MS?)

    Once in a while it'll stumble on an .inf, looks like it imports OK:

    Exception calling "Substring" with "2" argument(s): "Length cannot be less than zero.
    Parameter name: length"
    At C:\Temp\ImportDriver.ps1:126 char:54
    + ... te -gt 0) { $PercentComplete = $PercentComplete.ToString().Substring( ...
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentOutOfRangeException

Leave a Comment

Your email address will not be published. Required fields are marked *