SCCM - Updating all drivers after a migration

Published January 20, 2016 by FoxDeploy

Depicts an image saying 'Scripting System Center Configuration Manager'

This post is part of the ‘Scripting SCCM’ series on FoxDeploy, click the banner for more!

Every time you migrate from one SCCM instance to another, or if you have to move your drivers around (for instance: you originally had your drivers placed on the c:\ and want to mover them to another drive), you’ll need to update the location not only of DriverPackages, but also of all drivers as well.

This has been something that I MIGHT have forgotten more than once.  More than twice even.

So I wrote up this script.

This script assumes that you’ve already moved your drivers from their original location to their final resting place.  It also supports adjusting the path based on driver folder as well.  I’m a firm believer that SCCM Drivers should be stored in as small a folder structure as is possible, here’s how I normally layout my content for SCCM:

Type Of Content Location Shared Path
All SCCM Content D:\ContentSource \\SCCM\Content\
Drive Source Files D:\ContentSource\Drivers \\SCCM\Content\Drivers
Driver Packages D:\ContentSource\DriverPackages \\SCCM\Content\DriverPackages

So when I saw that this instance of SCCM had the content in the C:\ drive, and also had very long path names, I had to truncate things.  That’s why in this script, you’ll see separate logic for HP, Dell and Sony Drivers, as we needed to shorten those paths a bit.

Original Path New Path
Drivers\HP Drivers Drivers\HP
Drivers\Dell Drivers Drivers\Dell
Drivers\Sony Drivers Drivers\Sony

Assuming you’re moving your drivers from one system, to another, simply update the path on lines 8, 16 & 24.  If you don’t need to change folders, like I’m doing, then you can delete the three blocks and only use one.

Finally, this will take a LONG, LONG time.  We had ~3,000 drivers and it took about three hours or so.

Output looks like this:

[code language=”powershell” highlight=”8,16,24”] Set-CMQueryResultMaximum -Maximum 5000

$drivers = get-cmdriver

foreach ($driver in ($drivers)) {

If ($driver.ContentSourcePath -like "*PackageSource*hp drivers*"){ $newPath = $driver.ContentSourcePath -replace ‘PackageSource\\Drivers\\HP Drivers’,’DriverPackages\HP’ Write-host -ForegroundColor Cyan "Changing PkgSourcePath for $($driver.Name)…" $newPath Set-CMDriver -Id $driver.CI_ID -DriverSource $NewPath timeout 5 }

If ($driver.ContentSourcePath -like "*PackageSource*dell*"){ $newPath = $driver.ContentSourcePath -replace ‘PackageSource\\Drivers\\Dell Drivers’,’DriverPackages\Dell’ Write-host -ForegroundColor Cyan "Changing PkgSourcePath for $($driver.Name)…" $newPath Set-CMDriver -Id $driver.CI_ID -DriverSource $NewPath timeout 5 }

if ($driver.ContentSourcePath -like "*PackageSource*sony*"){ $newPath = $driver.ContentSourcePath -replace ‘PackageSource\\Drivers\\Sony Drivers’,’DriverPackages\Sony’ Write-host -ForegroundColor Cyan "Changing PkgSourcePath for $($driver.Name)…" $newPath Set-CMDriver -Id $driver.CI_ID -DriverSource $NewPath timeout 5 }

} ```

Microsoft MVP

Five time Microsoft MVP, and now I work for the mothership

Need Help?

Get help much faster on our new dedicated Subreddit!

depicts a crowd of people in a night club with colored lights and says 'join the foxdeploy subrreddit today'

Blog Series
series_sml_PowerShellGUI series_sml_IntroToRaspberryPi Programming series_sml_IntroToWindows Remote Management Series The Logo for System Center Configuration Manager is displayed here Depicts a road sign saying 'Learning PowerShell Autocomplete'

Blog Stats