How to change the SCCM 2012 Package Source Path with PowerShell

Let’s assume you’ve just created a larger number of packages within SCCM 2012 and then you’re asked to move the package sources to a different location. I guess no-one on earth would want to visit each package and update the data source manually, So I wrote 2 scripts that automate this task. It could actually be done with one script, but when it comes to changing such things I prefer to validate things.

As you can see from the screen shot below, we have 2 packages, with their Source Folder pointing to \\labsccm01\sources\Packages\App1 and \\labsccm01\sources\Packages\App2

package1

Now we want to change the Source path from \\labsccm01\sources\Packages\App1 to \\labsccm01\sources\NewPackages\App1 and \\labsccm01\sources\Packages\App2 to \\labsccm01\sources\NewPackages\App2

The script does not move the actual content, so before running the scripts below, the source must be copied to the new location.

First we are going to look for packages that have their content stored under \\labsccm01\sources\Packages by running the following PowerShell script.

Note: Before running the below script make sure you’re connected to the site through PowerShell.  Also make sure to set the variable $OldPath1 according to your environment.

 

The output generated looks as following.

packag2

If we are sure that these are the packages we want to change, we copy paste the content and store into a new file called Update_Package_SrcPath.txt. Then open CMPackage_Update_SourcePath.ps1 containing the code below. Edit the variables $OldPath, $OldPath1 and $NewPath. If you just want to simulate things, add –whatif to the line that starts with Set-CMPackage

package3

Going back to the Console we see the updated Source folders.

pacakge4

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

Spam Protection by WP-SpamFree