PowerShell: Modify Source Location for SCCM Drivers

I recently ran into an issue where eh hmm.. someone (not sure who but his initials are WB) imported a new set of drivers from a UNC path that was named incorrectly.¬† ūüėź

To be exact, the directory was named “\\DFS\NameSpace\Share$\OSD\Win7\x64\DriverSrc\Lenovo S32_x64_R01” when in reality it was supposed to be “\\DFS\NameSpace\Share$\OSD\Win7\x64\DriverSrc\Lenovo E32_x64_R01″.

There are quite a few drivers that were imported for this particular model and there is no way in the console to bulk change the source path so after renaming the source folder to E32, off to PowerShell I went.

As you might guess I opened the PowerShell (x86) Console from the SCCM Admin Console (Still on Sp1 CU3 so no x64 PowerShell for me yet).

First I need to retrieve the driver objects that have the invalid path:
$Drivers = Get-CMDriver | Where-Object ($_.ContentSourcePath -like “*S32_x64*”}

This process takes a while as I have a lot of drivers.  If your really bored you can watch the SMSProv.log instead of stare at the PowerShell console waiting for the command to end.

Once the command completes I  have a new variable ($Drivers ) filled with all the driver objects I need to target to fix this mishap created by whoever that attention deficit admin was.  (*cough*).  For sanity sake I echo the contents out to the screen to validate I have only what I need in the variable:

$Drivers | Select-Object ContentSourcePath

I now know I have all the desired drivers that I need to modify.  My goal is to simply replace S32 with E32 in the existing path.  The command I used:

foreach ($driver in $xBackupDrivers) {$oldPath = $driver.ContentSourcePath; Write-Host “OLDPATH: $oldPath”; $NewPath = $driver.ContentSourcePath -replace “S32″,”E32”; Write-Host “NEWPATH: $NewPath”; Set-CMDriver -Id $driver.CI_ID -DriverSource $NewPath}

An easier way to read this:

foreach ($driver in $xBackupDrivers) {
    $oldPath = $driver.ContentSourcePath
¬†¬†¬† Write-Host “OLDPATH: $oldPath”
¬†¬†¬† $NewPath = $driver.ContentSourcePath -replace “S32″,”E32”
¬†¬†¬† Write-Host “NEWPATH: $NewPath”
    Set-CMDriver -Id $driver.CI_ID -DriverSource $NewPath
}

I have highlighted the commands that are doing the actual work.¬† I simply replace the text into a new variable and pass that to the “Set-CMDriver” cmdlet (Along with the driver CI_ID).

About¬†30 seconds¬†later the drivers have the correct source path.¬†¬†I’m now off¬†to reprimand that SCCM Admin!

 

Advertisements

Adding Duplicate Drivers to SCCM 2007 SP1

Another one of the most glaring deficiencies in my opinion with OS deployment using SCCM is the inability to import the same drivers for different models.¬† I personally prefer to import ALL drivers for every model of machine I have versus trying to dig through other imported drivers and piece together what each model actually needs.¬† It can be quite frustrating to say the least.¬† I break up my drivers by model and would love to out of the box (I believe this may be addressed in SP2) simply import the entire driver set in each subfolder, then create a package per model and assign the drivers from the subfolders to their respective package.¬† Well the good news is you CAN!¬† You simply have to trick SCCM into allowing you to do this.¬† Its quite simple actually. SCCM bases whether drivers are the “same” based on the calculated hash value of the driver files.¬† By simply adding a unique text file to the driver folder it creates a different hash value and allows you to import them even if the actual drivers have already been imported.¬† How I do it:

Break your drivers down by model in their own subfolders:
Example:
\\Server\share$\Drivers\Latitude E6500\Audio
\\Server\share$\Drivers\Latitude E6500\Video
Etc..

\\Server\share$\Drivers\Latitude E4300\Audio
\\Server\share$\Drivers\Latitude E4300\Chipset
etc..

Now open the root folder and create a new txt file based on the model.
Example:
\\Server\share$\Drivers\Latitude E4300\Latitude E4300.txt

Now copy this file to your clipboard, then do a windows search within the root directory for “*”.¬† Sort by type to gather all the folders at the top of the search.¬† Right click on EACH folder within the search and past the model specific txt file.

Do this for each of your driver sets and when you import them into their own sub-folder under the drivers node they will import even if the actual driver has already been imported.¬† ūüôā¬† you can now make corresponding packages for each model all with their OWN version of their drivers.

I know this has made my life SO much better with managing drivers in SCCM.  I hope it helps someone else.

*UPDATE* – A MUCH quicker and simpler way to create the txt file in your driver folders can be found here:
http://myitforum.com/cs2/blogs/jsandys/archive/2010/04/05/duplicate-drivers-helper-script.aspx