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).
- 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.
- 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. cm01.viamonstra.com
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. \\FileSrv01.viamonstra.com\sccm_sources$\OSD\DriverSources and in
Driver package type the destination e.g. \\FileSrv01.viamonstra.com\sccm_sources$\OSD\DriverPackages - Launch the script from PowerShell to start the import. The script will automatically import the drivers, create unique driver categories and driver packages.
- You can re-run the script multiple times, it will only import new drivers.
Will it work on SCCM 2007?
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 DriversSources tree. Can I re-run this script or will it cause problems trying to re-import all the drivers from before?
Yes, only new drivers will be imported
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:sourcesscriptsimportdrivers_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 Esourcesscriptsimportdrivers_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: http://gallery.technet.microsoft.com/Powershell-script-to-add-40a24d35/view/Discussions, in an attempt to find typos but didn’t make any progress.
Is it the script or do I have a wmi issue?
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
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.
This can also be caused by accidentally having a at the end of the UNC paths to Driver Source and Driver Package as was my case.
[…] 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 […]
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?
Nevermind I found that I had my folder structure wrong.
[…] http://blog.coretech.dk/kea/automate-importing-and-creating-drivers-packages-in-sccm-2012-r2/ […]
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.
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.
Great script, but for some reasons create duplicates for me if ran multiple times… Any idea what can be cause of that?
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!
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.
I usually run this:
Get-ChildItem G:FOLDER_SOURCEDRIVERS*.hash -recurse | Remove-Item -Confirm
Where “G:FOLDER_SOURCEDRIVERS” is the location path UNC or local where your driver bits are located. this will remove all the *.hash files up on confirmation from each folder that the script previously scanned… what the .hash file does is simply tell the script that already checked that folder for drivers and does not need to go through it again.
[…] Driver Import Script http://blog.coretech.dk/kea/automate-importing-and-creating-drivers-packages-in-sccm-2012-r2/ […]
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
Great books and scripts.
I get the same error too:
Exception calling “GetBytes” with “1” argument(s): “Array cannot be null.
Parameter name: chars”
At E:ToolsMicrosoftSCCMScriptImportDriversDeloyImportDrivers.ps1:154 char:2
+ $hash = [BitConverter]::ToString($crypto.ComputeHash([System.Text.Encoding]::UT …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ArgumentNullException
For got to add running on CM Current Branch 1602.
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 ?
Thanks
Philippe
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 ?
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!
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: \W479P0VSCCM_Sources$OSDDriverSources
————————————————————————————————————
————————————————————————————————————
Processing Folder: Win7_x64
————————————————————————————————————
—————————————————————————————————-
Processing Folder: Win7_x64Dell
—————————————————————————————————-
——————————————————————————————–
Processing Driver Package: Win7_x64_Dell_Optiplex 7010
——————————————————————————————–
get-wmiobject : Generic failure
At D:joeImportDrivers.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:joeImportDrivers.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:joeImportDrivers.ps1:121 char:3
+ $InParams.TargetContainerNodeID = $TargetFolderID
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
+ FullyQualifiedErrorId : CatchFromBaseAdapterSetValue
Exception calling “InvokeMethod” with “3” argument(s): “Generic failure ”
At D:joeImportDrivers.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.
Reading through this more closely, the hierarchy may be working as intended, just not what I thought I would get.
I’m expecting
Win7_x86
Dell
Optiplex 7010
Guid1
Guid2
I’m getting
Win7_x86
Dell_Optiplex_7010
Guid1
Guid2
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.
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?
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
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.
[…] helper script here. If you’d like to automate the above with a PowerShell script then try this one from Kent […]
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 GitHub.com https://github.com/Duffney/SCCMPowerShell/blob/master/Get-CABfiles.ps1.
Do you still have the script that will extract .cab files and put them in the format needed for import into SCCM as referenced in http://blog.coretech.dk/kea/automate-importing-and-creating-drivers-packages-in-sccm-2012-r2? I tried the link provided, but apparently the .ps1 file is no longer there.
[…] “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 […]
Love…. You…..
This is awesome. Thanks so much.
[…] Driver Import Script – http://blog.coretech.dk/kea/automate-importing-and-creating-drivers-packages-in-sccm-2012-r2/ […]
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
I usually run this:
Get-ChildItem G:FOLDER_SOURCEDRIVERS*.hash -recurse | Remove-Item -Confirm
Where “G:FOLDER_SOURCEDRIVERS” is the location path UNC or local where your driver bits are located. this will remove all the *.hash files up on confirmation from each folder that the script previously scanned… what the .hash file does is simply tell the script that already checked that folder for drivers and does not need to go through it again.
If you don’t remove the .hash file from each folder as I am suggesting in the posting before the script will tell you that there is nothing new to add, in other words “nothing has changed” hence needing to remove those .hash files ….. I bet you copy the drivers source after scanned and keep reusing it without removing this file.
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.
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.
Ayo,
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?
Thanks
Ed
Never mind…. I got it!
thanks all for the clues!
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.
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.
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?
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!
Thanks!
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? :/
Thank You, Oskar for sharing your solution,
it’s working for me!
Kent, realy great script…
FYI:
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!
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?
It will be helpful if i can get reply for above question soon since we are in process of implementing 2012
Thanks in Advance
[…] http://blog.coretech.dk/kea/automate-importing-and-creating-drivers-packages-in-sccm-2012-r2/ […]
The script ran, but when it completed it created multiple driver packages for audio, chipset, video etc… instead of just one driver package.
Script works great, i am only having 1 issue. Driver Packages are being created for every folder under the main folder, example Elitebook 755, there are 5 driver packages? Is there a way to create 1 complete package containing all of these?
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?
ConfigMgr 2012 R2 1602 , script has run without any problems.
Hello,
I ran the script and it worked but I had the folder naming convention wrong. I deleted all the drivers from drivers and driver packages. Now that I want to run it again it keeps saying no changes has been made to this driver package. skipping. Any way to start fresh again? Please advise.
Great script!!
Thank you,
Jorge,
There will be hash files that get created in each folder named “54B099710F0EB7384E823B6CDB15BC53.hash” as an example. If you delete these files, the script will think it never imported the drivers and will re-import.
Eric
I usually run this:
Get-ChildItem G:FOLDER_SOURCEDRIVERS*.hash -recurse | Remove-Item -Confirm
Where “G:FOLDER_SOURCEDRIVERS” is the location path UNC or local where your driver bits are located. this will remove all the *.hash files up on confirmation from each folder that the script previously scanned… what the .hash file does is simply tell the script that already checked that folder for drivers and does not need to go through it again.
Thank you Erick and Ed..
Great script, saves heaps of manually work!
[…] Batch OSD Driver Import Script (Kent Agerlund) […]
[…] So, I tweeted some nonsense about writing a PowerShell script to batch import Applications (or Packages?) into System Center Configuration Manager (aka SCCM, aka ConfigMgr, aka OMG this is a long name). The idea isn’t new or original, and there may be another script already out there to do just that. But I got the idea from dealing with bouncing in and out of customer environments and doing packaging projects for various places, etc. The other part of this hair-brained idea came from seeing what Kent Agerlund had done with importing drivers. […]
Can this be used within MDT? I know it will need to be tweaked. Any help would be great.
no, it uses CM code extensively
SCCM 2012 1606- I have the issue, when I run this multiple times against my driver source even that there is a HASH file in the all folders, in some cases it starting duplicate drivers.
Any ideas?
Thank You in Advance.
[…] SCCM Driver Import Tool: http://blog.coretech.dk/kea/automate-importing-and-creating-drivers-packages-in-sccm-2012-r2/ […]
The download link is broken. Same with all the other tools.