Credit to Greg Ramsey for writing the script.

In addition to this post, be sure to read John Marcum’s blog post:

Packages Will Not Uncompress After Using Preloadpkgonsite.exe

After upgrading a few servers at a client site, we had to reinstall the Secondary Sites. Surprisingly we didn’t want to resend 400+ packages across the WAN to the remote sites.  The PCK files were still sitting on the server from the previous installation. 

After reading John’s post and chatting with Greg Ramsey, I decided to use his script.  I had a few issues initially and Greg being the awesome guy he is helped me sort them out. 

One VERY important thing to note is that you have to send at LEAST one package to the remote site before you can preload content, not sure why that is the case, but John saw the same thing.  After sending one package, the preload tool works great. 

Once you have the script, you’ll need to make sure the paths are correct for your environment and it’s pointing to the correct server.

Make sure the connection string is pointing to the right server and site code.

image

Make sure the SMSPKG folder paths are correct.

image

Make sure the output path is correct as well.

image

Next we want to run the createpreloadbat.ps1 script in powershell.

image

You will end up with a preloadpck.bat in the output path and you will see the script spit out all the PCK’s it found.

image

image

Next if you run the preloadpck.bat, you will see it update the database. You will see it make the connection to the database and it will let you know if there are any issues.  (in this example screenshot the packages are already distributed)

Again, remember you have to send at least one package ahead of time (pick a small one), otherwise you’ll see a rights error.

image

Finally you can add your DP to the package using the copy packages wizard or CloneDp or whatever you want to use. When the DP receives the request for the package it will use the local PCK instead of requesting a new one.

Enjoy!

Download the script here.