Small useful scripts–Changing Driver Package source (PS1)

I have this customer who had to move all driver packages from from one server a another. This of cause meant all the Data Source references had to be change as well.

Once al the packages were moved to the new server I ran the following  two scripts to change the source. All you need to change is the $Site to your site code, or add it is a parameter when you run the script. You will obviously also have to type in the old and new path.

Syntax: Script.ps1 –Site XXX

If you want to only run against one driver/package for testing you can also add the ID as a parameter

Syntax: Script.ps1 –ID XXXXXXXX –Site XXX


Driver packages

About the Author:

Michael Petersen
Twitter: @OSDeployLinkedin: Michael PetersenMicrosoft Community Contributor


  1. Squidjigg October 18, 2012 at 3:40 - Reply

    Thanks for the awesome scripts! During a migration, I completely changed the driver destination folder structure, and these scripts made it so easy to update the source paths! One note though, you’re missing a “w” in the drivers script where it reads “here-object”.

  2. discontinuity April 11, 2013 at 8:03 - Reply

    Hi, this is the script that I was looking for 🙂 But couldn’t make it work, I’m sure you have tried and tested it before you put it here but that double slashes confused me. I also tried to run it with package id but nothing happened. I have changed the driver packages’ content sources manually but I also have around 800 drivers to be changed. Is there any ID for individual drivers?

  3. Ben May 13, 2013 at 9:31 - Reply

    For drivers, it’s not PackageID, but CI_ID:
    $drivers | here-object{$_.ContentSourcePath -like “OldServerOldShare*” -and $_.CI_ID -like $ID} |

    Also nice to know: in the replace, the string “” should be like this: “\”, but only in the first string:
    ForEach-Object{$_.ContentSourcePath = $_.ContentSourcePath -replace “\\OldServer\OldShare”, “\NewServerNEWShare”; $_.Put

    But thanks for the script! It helped me a lot!

  4. Ben Dover June 11, 2013 at 4:44 - Reply

    Hey Ben, you missed the comment by squidjigg!!! peeps, don’t forget to change here to where…hey blog owner, please update this blog entry so it has the correct syntax. Other than that, it works.T

  5. AdrianR July 1, 2013 at 7:18 - Reply

    Also worth noting is that any hidden shares, ie, ones with a “$” sign will need to have the any dollar signs escaped with an additional backslash, only required in the string to find.

    Otherwise, thanks for the great script.


    1 param($ID = “*”,$Site = “CEN”)
    3 $drivers = Get-WmiObject SMS_Driver -Namespace rootSMSsite_$Site
    5 $drivers | where-object{$_.ContentSourcePath -like “OldServerOldShare$*” -and $_.PackageID -like $ID} |
    6 ForEach-Object{$_.ContentSourcePath = $_.ContentSourcePath -replace “OldServer\OldShare$\”, “NewServer\NEWShare$”; $_.Put()}

  6. Rusty August 23, 2013 at 20:49 - Reply

    Not sure what I’m doing wrong here. This is what I’m getting when I try to run the script.

    Property ‘ContentSourcePath’ cannot be found on this object; make sure it exists and is settable.
    At C:Userscarterjrupdate_drivers.ps1:4 char:19
    + ForEach-Object{$_. <<<< ContentSourcePath = $_.ContentSourcePath -replace "usas24\data sources for sccm", "usas11\d
    ata sources for sccm"; $_.Put()}
    + CategoryInfo : InvalidOperation: (ContentSourcePath:String) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    You cannot call a method on a null-valued expression.
    At C:Userscarterjrupdate_drivers.ps1:4 char:141
    + ForEach-Object{$_.ContentSourcePath = $_.ContentSourcePath -replace "usas24\data sources for sccm", "usas11\data so
    urces for sccm"; $_.Put <<<< ()}
    + CategoryInfo : InvalidOperation: (Put:String) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Here is the script as I edited it. Obviously my old server is usas24 and the new one is usas11. The paths are all the same.

    param($ID = "*",$Site = "US2")

    $drivers | where-object{$_.ContentSourcePath -like “usas24\data sources for sccm*” -and $_.CI_ID -like $ID}

    ForEach-Object{$_.ContentSourcePath = $_.ContentSourcePath -replace "usas24\data sources for sccm", "usas11\data sources for sccm"; $_.Put()}

    Any help would be greatly appreciated as there are hundreds of drivers to be remapped.



  7. Rusty August 24, 2013 at 1:20 - Reply

    Figured out the problem script worked fine once I made the necessary corrections.

  8. Claes Abrahamsson October 28, 2013 at 13:29 - Reply

    Had to make a few adjustments in order to get this working.

    $drivers = Get-WmiObject SMS_Driver -Namespace rootSMSsite_002

    $drivers | where-object{$_.ContentSourcePath -like “\oldserverSource$Drivers*” -and $_.Package_ID-like $ID} | ForEach-Object{$_.ContentSourcePath = $_.ContentSourcePath -replace “\\OLDSERVER\Source$\Drivers”, “\\company.localdfssccmsources$Drivers”; $_.Put()}

  9. Dion May 15, 2014 at 9:03 - Reply

    Really useful script!

    Just a note of caution however, use caution when running this against many driver packages since the Put() method forces an update on the package to all DP’s, if you do this to many at once then you might be in for some pain, task sequences may stop running etc.. At least this is the case for SCCM 2007 SP2 R3, I haven’t tested others.

    An alternative it to do the same via TSQL directly in the database. Don’t normally recommend direclty modifying the database but in this case it makes some sense since this doesn’t trigger the package refresh, and the TSQL statement runs much faster too 🙂

  10. sebus April 26, 2016 at 13:41 - Reply

    TSQL can easily be run for Driver Package

    , REPLACE(pkgSourcePath,’\sp-v-sccm’,’\sp-v-sccm-cb’) AS NewContentSourcePath
    FROM dbo.v_package
    WHERE pkgSourcePath LIKE ‘%\sp-v-sccm%’

    but as for the driver, it is not possible with just SQL, cause:

    The complete “Driver Source” (including driver file name) is not a simple field within any of the SCCM tables. As it turns out, driver information is embedded within an XML field called SDMPackageDigest that itself is part of the CL_ConfigurationItems table.

    as per

  11. sebus April 26, 2016 at 14:19 - Reply

    It does nothing with SCCM 2012 R2
    No replacement happens at all (and no error)

Leave A Comment