Automate importing and creating driver packages in SCCM 2012 R2


I take that you are familiar with drivers and manually creating driver categories and driver packages in Configuration Manager. Here I will show you how you can optimize the process by running a very need little PowerShell script called ImportDrivers.ps1 (main developer is Claus Codam).

  1. There are a few prerequisites that needs to be in place before the script will work.

    Driver source has to be 3 levels deep like this example (Make\Model\OS). The driver source is where you store the original driver packages from the vendor.


    You need to create a Driver packages folder (where ConfigMgr will import the drivers to). The script will automatically create a folder using folder names in Driver Sources.


  2. Open the ImportDrivers.ps1 script and modify the last two lines in the script as in this example.

    New-SCCMconnection: add the FQDN of your site server e.g.

    SMSSiteCode: Type your site code e.g. PS1

    Driver source: Type the unc to the toplevel of the driver source (the location where you have the original drivers) e.g. \\\sccm_sources$\OSD\DriverSources and in
    Driver package type the destination e.g. \\\sccm_sources$\OSD\DriverPackages


  3. Launch the script from PowerShell to start the import. The script will automatically import the drivers, create unique driver categories and driver packages.


  4. You can re-run the script multiple times, it will only import new drivers.

Comments (47):

  1. R says:

    Will it work on SCCM 2007?

  2. Mike says:

    What happens if I run this multiple times against my driver source folder?

    Let’s say I get a new model. I add the drivers to the Drivers\Sources tree. Can I re-run this script or will it cause problems trying to re-import all the drivers from before?

  3. Mike says:

    Yes, only new drivers will be imported

  4. RD says:

    I believe the pre-requisites are in place, but I’m getting an error. The script is running locally on a SCCM 2012 R2 site on Server 2012 R2.

    Started Importing…
    Processing Folder…
    Processing Driver package…
    Creating new driver package… (next is the error)
    Set-wmiinstance : generic failure
    At e:\sources\scripts\importdrivers_1.pst:64 char:19
    +$newPackage = set-wmiinstalce -class sms_driversPackage -arguments $arguments …
    +categoryInfo : invalidOperation: (:) [set-wmiinstance], managmentexception
    +FullyqualifiederrorID : setwmimanagmentexception,microsoft.powershell.commands.setwmiinstance

    and another error right after this.

    Exception calling “invokemethod” with “3” argument(s): “Generic failure ”
    At E\sources\scripts\importdrivers_1.ps1:122 char:3
    +$null = $wmiconnection.psbase.invokemethod($Method,$InParams,$null)
    + CategoryInfo : NotSpecified (:) [], MethodInvocationException
    +FullyQualifiedErrorID : DotNetMethodException

    In the console:
    I see drivers have been imported and categorized according to the folders I creates under driver sources.
    I see that one top level folder was created under driver packages, but nothing underneath that.

    On the file system:
    I see that the second level folder was created under DriverPackages, but nothing underneath that.
    I also see a hash file created in each level 3 folder, where the drivers reside.

    I looked at this link:, in an attempt to find typos but didn’t make any progress.

    Is it the script or do I have a wmi issue?

    • Niklas says:

      Experienced the exact same errors! This was fixed by adding permissions to the share for the SMS Provider computer.

      1.Right click on the folder that has the share
      2.Click the Sharing tab
      3.Click Advanced Sharing
      4.Click Permissions
      5.Click Add, add “System”, click OK
      6.Click to highlight “System”, click Full Control, click OK twice and Close

      • RD says:

        Thank you Niklas. That was the issue and now it’s working perfectly!

        I previously added the Everyone group with Full Control under Share permissions, not realizing that Everyone excludes the System and Network accounts. This should help others like me out. Thanks again.

  5. […] repository. If you don’t want to go ‘all in’, like when you’re using the Coretech tool: this little script that I’ve created might come in […]

  6. Jared Larkins says:

    Quick question. I may not be doing something right. But when the script creates the driver categories should it label them as MODEL_DriverPackagefiles_”A GUID OF SOMEKIND”? Or am I just not structuring my folders properly?

  7. Mike says:

    I am having the same issue RD. The only difference is that my Source and package directories are stored on a network drive (NAS). I am pretty sure this is a permissions issue as Niklas has pointed out, but I have given the CM server full access via share and ntfs. Any help would be much appreciated.

  8. Mike says:

    Never mind. My powershell skills are not so hot. Once I set the execution policy (for the local machine) to Unrestricted, my errors went away.

  9. Alex says:

    Great script, but for some reasons create duplicates for me if ran multiple times… Any idea what can be cause of that?

  10. ed davis says:

    Thanks for the great script!

    How can I easily have the script read the folders that are separated by x86 and x64 for the dell images other than manually moving the x64 and x86 folders up a level? The script is importing the main folder (32 and 64 bit drivers) into one package.

    Thanks again!

  11. Steffen says:

    Thanks for a great script. just have a little but.
    The hash values that are created, seems to be user specific?
    I am working for a customer, where I imported all their drivers this way, and when they used it them self,
    it went through all drivers one by one, processing and discovered they allready exists.
    The script ran for hours, and at some point it was finished
    I tried to run it my self again after, and the same thing happened, it ran for hours just discovering that they allready exists.
    The first time i ran the script, I ran it a couple of times, and those times it went throug in seconds.

  12. Merton Bruce says:

    I am getting errors when I run the script.
    Exception calling “GetBytes” with “1” argument(s): “Array cannot be null.
    Parameter name: chars”
    At C:\Import.ps1:154 char:2
    + $hash = [BitConverter]::ToString($crypto.ComputeHash([System.Text.Encoding]::UT …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

  13. Philippe A says:

    Hello, thanks a lot for this helpfull script.
    By the way i have a problem with using it, i get no error during the execution of the script, but nothing is done.

    drivers are not imported.

    i have the normal message : “processing folder”… but then the scripts end and nothing have been imported into driver package destination path.

    Can someone help ?

    • Philippe A says:

      let it go i found the solution of my issue.
      I didn’t respect the folder sources architecture…

      But now i have another issue,

      when the script run, it create a bad folder name in the destination path, for example if i have a folder “Lenovo” in the sources, it create me in the destination path a folder “enovo” without the first letter.

      Any idea ? should it be an issu with the original script ?

  14. I just wasted the last 2 hours of my life trying to create something that does just this. The good news is I don’t have to waste any more of my life! Thanks!

  15. JoeZeppy412 says:

    My forehead hurts from beating it off the desk. This script is not working for me, and seems to fail in random ways. Now I’m getting the same error others get.

    Started Importing Driver Store: \\W479P0V\SCCM_Sources$\OSD\DriverSources

    Processing Folder: Win7_x64

    Processing Folder: Win7_x64\Dell

    Processing Driver Package: Win7_x64_Dell_Optiplex 7010
    get-wmiobject : Generic failure
    At D:\joe\ImportDrivers.ps1:365 char:21
    + $CMPackageTrue = (get-wmiobject -query “Select * from SMS_DriverPackage join S …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    get-wmiobject : Generic failure
    At D:\joe\ImportDrivers.ps1:366 char:52
    + if ($CMPackageTrue -eq $null) { $CMPackageTrue = get-wmiobject -query “Select …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
    + FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand

    Creating new driver package Win7_x64_Dell_Optiplex 7010
    Exception setting “TargetContainerNodeID”: “Cannot convert value “deID=226” to type “System.UInt32”. Error: “Input
    string was not in a correct format.””
    At D:\joe\ImportDrivers.ps1:121 char:3
    + $InParams.TargetContainerNodeID = $TargetFolderID
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : CatchFromBaseAdapterSetValue

    Exception calling “InvokeMethod” with “3” argument(s): “Generic failure ”
    At D:\joe\ImportDrivers.ps1:122 char:3
    + $null = $WMIConnection.psbase.InvokeMethod($Method,$InParams,$null)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    source, destination and console are on the server I’m sitting at, sccm server is remote. Server machine accout has admin rights to this server. I have admin rights to both servers. Everyone I can think of has full control to the share and NTFS, machine accounts, SYSTEM

    I can run WMIC to the local server and the remote. I tried running it on the CAS, no different.

    I had the above error, then it went away, now its back. In any case, I never, ever, ever get the proper hierarchy. Folders are created, but I never get the third level deep. The package usually ends up at the root. This is killing me.

  16. JoeZeppy412 says:

    Reading through this more closely, the hierarchy may be working as intended, just not what I thought I would get.
    I’m expecting
    Optiplex 7010

    I’m getting

    I can live with that, though its not what I want, but I still am getting errors creating the folders and categories in SCCM.
    But then it creates them anyway. wth?
    The drivers get the categories assigned, but the packages don’t go into the console folders. They are all at the root. If I create the categories manually, the script will use them, and put the packages into thm. but it won’t do it on its own.

  17. Yamini says:

    When I download the file it downloads as a .rar file and when I save it as a ps1 file it has foreign characters in it. Is this the correct file to download?

  18. Yamini says:

    When I download the file it downloads as a .rar file and when I save it as a ps1 file it has foreign characters in it. Is this the correct file to download? yamini

  19. Kevin Schumaker says:

    Love this script, saved me a ton of time, great work!

    I do have a question though, I am still learning PowerShell and working my way through the script and have not quite been able to modify it to do what I want next.

    I would like the ability to split the script up a bit and the functionality I want is this.

    I already have Categories and Packages created and named the same, but I need an automated way of adding the drivers to the packages by category name.

  20. […] helper script here. If you’d like to automate the above with a PowerShell script then try this one from Kent […]

  21. This is a great script that has saved me countless hours, thank you so much for creating this! I spent a little time and wrote up a PowerShell script that will extract .cab files and place them in the format needed. If anyone is interested you can check it out on

  22. […] “Automate process to import drivers and create driver packages.” – Kent Agerlund and “Automate, Automate, Automate. Manually building images is not what anyone should be paid for. It’s a waste of money and time.” – Jason Sandys […]

  23. Jim Bullock says:

    Love…. You…..

    This is awesome. Thanks so much.

  24. Ayo Dada says:

    i deleted the folders after i ran the script and i cannot get it to work it keep saying no change has been made to the package skip can you help urgently, i have deleted all folder manually and packages from the driverpackage folder but no change is there a log file i need to delete

  25. Ayo Dada says:

    Issue resolved when the importDriver.ps1 script runs it puts a.hash file under each of the DriverSource folders in the file structure.I Deleted HASH Files in each model folder and it reprocessed again then recreated all packages and imported them into the SCCM Driver package node again.

    • Steffen says:

      what do you mean by “issue resolved”.?
      When you delete the hash value it should reprocess all again.
      My issue was that I think some user specific is in those hash, and when I run it, and then somebody else runs it after, it will reprocess completely again.
      But if one person runs this 2 times, the second time will go fast.

    • Ed says:


      You seemed to have run through the same or similar issue I am experiencing in my process (or something like that) when you say:

      “Issue resolved when the importDriver.ps1 script runs it puts a.hash file under each of the DriverSource folders in the file structure.I Deleted HASH Files in each model folder and it reprocessed again then recreated all packages and imported them into the SCCM Driver package node again”

      Tell me exactly what do you mean, where exactly is that.hash file created?



  26. Tyler says:

    First, i love the script.
    Second, is there a way to slightly modify the script so that duplicates will not import, but an additional/New Category will be added to existing drivers? I do not currently see this effect.

  27. Brandon says:

    I’ve created my own PS script using the Configuration Manager Cmdlets that does this same thing.
    I’ve also ran your script along with mine to compare the speed hoping yours was faster.
    Unfortunately neither yours nor mine seem to come close to matching the speed of a mass driver import from within the SCCM Console. Taking easily 2-3x as long.
    I find that our scripts take way too long at the step where it actually does the import of the driver.
    I still like the idea of running our scripts but was wondering if you experienced any better import times than I am.

  28. Ed says:

    Team, the script is working fine for me …. what I am having an issue with is… while in the process of understanding the “three folder level deep” hierarchy I imported many drivers, in many opportunities that are currently indentified in the drivers catalog with its appropriate GUID, so when I was trying to test some other variations the drivers packages do not show up anymore (because I previously deleted them through the UI… by first removing all the categories created) so my question is…. is there a simple way to remove any drivers previously imported in to ConfigMgr from the driver catalog in an elegant and clean way via powershell?

  29. Oskar says:

    I had an issue where Dell named some of their directories in their driver packages with a .inf extension. I added -File to row 411 of the script and now it reads:
    Get-ChildItem $package.FullName -File -Filter *.inf -recurse | % { SDS-ImportDriver $_ $CMCategory $CMPackage }

    Works perfect now!

    • Katper says:

      First, thank You for the scritp, it saves a lot of hours of work!

      I have the same issue as Oskar, unfortunately -File parameter didn’t help, i still have unexpected error in some cases.

      Error massage:
      Unexpected error, skipping INF : Failed to initialize driver digest. 13

      it cames with some of Lenovo and Dell drivers.
      Any ideas? :/

  30. MikeL says:


    With the recent ConfigMgr 2012 R2 SP1 release, there is an issue with driver package explosion. A 1 GB driver source can blow up to a 5 GB driver package. I decided to try this script. For some reason, this script bypasses the issues that the traditional driver catalog import has in R2 SP1. For example, using the traditional driver import for an HP EliteDesk 800, the source was 923 MB. The package was 3.78 GB. I deleted everything and used this script. The source and package match exactly. So, thanks!

  31. Raghunandan Prahlad says:

    Very Good Scrip. However there is one challenge.
    Since the duplicate entry will not process, the driver package folder will be empty.
    In Task Sequence, if we select this (empty driver package)for respective Model, it will not install any drivers and TS will fail.
    Do you have any alternative for this?

  32. Raghunandan Prahlad says:

    It will be helpful if i can get reply for above question soon since we are in process of implementing 2012

    Thanks in Advance

  33. Tyler says:

    The script ran, but when it completed it created multiple driver packages for audio, chipset, video etc… instead of just one driver package.

  34. John Hamilton says:

    Since upgrading to ConfigMgr 2012 R2 1602 the script doesn’t complete. Have there been other reports of changes with ConfigMgr that would have affected the script?

Leave a Reply