Change Driver Source Directories

less than 1 minute read

Don’t change the name of the driver source directory. Don’t ever do this.

If you decided to do this, here is a script which will help you. It will find all drivers whose source path starts with $OldPath. It will then replace the $OldPath with the $NewPath.  Of course, you need to specify the $SiteCode and $Server.

#Edit these four lines
$SiteCode = "PS1"
$Server = "CM12"
$OldPath = "\cm12sourceOSDDrivers"
$NewPath = "\cm12sourceOSDDriver Source"
 
#Don't edit below this line
$FindPath = $OldPath.Replace("","\")
Get-WmiObject -Namespace "rootsmssite_$SiteCode" -ComputerName $Server -Query "select * from SMS_Driver where ContentSourcePath like '$FindPath%'" | ForEach-Object {
	$ContentSource = $_.ContentSourcePath
	$ContentSource = [Regex]::Escape($ContentSource) -replace [Regex]::Escape($OldPath),[Regex]::Escape($NewPath)
	$_.ContentSourcePath = [regex]::Unescape($ContentSOurce)
	$_.Put()
}

Leave a Comment