Month: May 2014

ConfigMgr migration script – Driver source path conversion

Posted on Updated on

Use the following PowerShell script to convert driver files’┬ásource path from an old server location to the new location.

Updated 5/5/14: fixed creation of $ChangePath variable to account for mixed-case of the $OldPath and $NewPath.

# By https://t3chn1ck.wordpress.com
# Version 1.1

# Site Code + :
Set-Location "GAL:"

# Note: max query limit is 1000 items, need to increase value as appropriate
Set-CMQueryResultMaximum 2000

$DriverArray = Get-CMDriver
$OldPath = "\\2007SERVER\source$"
$NewPath = "\\2012SERVER\cmsource$"

ForEach ($Driver in $DriverArray){
   $OldPkgPath = $Driver.ContentSourcePath.ToLower()

   If ($OldPkgPath.StartsWith($OldPath)){
      $ChangePath = $OldPkgPath.Replace($OldPath.ToLower(), $NewPath.ToUpper())

      Set-CMDriver -Id $Driver.CI_ID -DriverSource $ChangePath
      Write-Host "Changed: " $Driver.CI_ID " to " $ChangePath -f Green
   } Else {
      Write-Host "Not changed: " $Driver.CI_ID " of " $OldPkgPath -f DarkYellow
   }
}