Sometimes there is a good reason to get out of your comfort zone. One of those reasons is moving the Source Directory of all packages to a different server/ share. This means there has to come a script to change the Source Directory of all packages, as it is not a job that you want to do manually, and scripting is not really my thing… But as it cost me some time to create something nice of it, I will share it so everyone can “enjoy it”.
I created three subroutines, one for connecting to the SMS Provider, one for changing the Package Source Path and one for change the Content Source Path. The Package Source Path counts for all the different types of packages and the Content Source Path only counts for Drivers. The only thing that needs to be adjusted is the old and the new location of the Package Source Directory. This script needs to be run from the Site Server.
Dim objSWbemServices
Set FSO = CreateObject (“Scripting.FileSystemObject”)
Set logFile = FSO.CreateTextFile (“PkgSourcePathLOG.csv”)sOldServerShare = “<SERVER>\<SHARE>”
sNewServerShare = “<SERVER>\<SHARE>”
ConnectToSMSProvider()
ChangePkgSourcePath(“SMS_Package”)
ChangePkgSourcePath(“SMS_SoftwareUpdatesPackage”)
ChangePkgSourcePath(“SMS_ImagePackage”)
ChangePkgSourcePath(“SMS_OperatingSystemInstallPackage”)
ChangePkgSourcePath(“SMS_DriverPackage”)
ChangeContentSourcePath(“SMS_Driver”)‘==================================
‘ Sub Routine to Connect to the SMS Provider
‘==================================
Sub ConnectToSMSProvider()
Set objSWbemLocator = CreateObject(“WbemScripting.SWbemLocator”)
Set objSWbemServices = objSWbemLocator.ConnectServer(“.”, “root\sms”)
Set ProviderLocation = objSWbemServices.InstancesOf(“SMS_ProviderLocation”)
For Each Location In ProviderLocation
If Location.ProviderForLocalSite = True Then
Set objSWbemServices = objSWbemLocator.ConnectServer(Location.Machine, “root\sms\site_” + Location.SiteCode)
End If
Next
End Sub‘==================================
‘ Sub Routine to Change the Package Source Path
‘==================================
Sub ChangePkgSourcePath(strClass)
Set colSWbemObjectSet = objSWbemServices.execQuery(“SELECT * FROM ” & strClass)
For Each objSWbemObject In colSWbemObjectSet
sOldPkgSourcePath = objSWbemObject.PkgSourcePath
sNewPkgSourcePath = Replace(sOldPkgSourcePath, sOldServerShare, sNewServerShare)
logFile.Write “Setting Package Source Path for ” & objSWbemObject.Name & ” from ” & sOldPkgSourcePath & ” to ” & sNewPkgSourcePath
objSWbemObject.PkgSourcePath = sNewPkgSourcePath
objSWbemObject.put_
Next
End Sub‘==================================
‘Sub Routine to Change the ContentSource of Drivers
‘==================================
Sub ChangeContentSourcePath(strClass)
Set colSWbemObjectSet = objSWbemServices.execQuery(“SELECT * FROM ” & strClass)
For Each objSWbemObject In colSWbemObjectSet
sOldPathString = objSWbemObject.ContentSourcePath
sNewPathString = Replace(sOldPathString, sOldServerShare, sNewServerShare)
logFile.Write “Setting Content Source Path for ” & objSWbemObject.LocalizedDisplayName & ” from ” & sOldPathString & ” to ” & sNewPathString
objSWbemObject.ContentSourcePath = sNewPathString
objSWbemObject.put_
Next
End Sub
Keep attention to the fact that changing the Source Directory will make the Distribution Point re-process the packages. This is the part that virtual application packages don’t like. They will generate lots of errors in the distrmgr.log and to fix it I had to touch them all and re-select the XML –file from the original project directory.