SCCM - Updating all drivers after a migration
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 }
} ```