RecoverDP.ps1

Hello everyone,

While working on an exciting internal project where we've been discussing Configuration Manager Disaster recovery plans for CAS, Primary sites, Secondary and DP's, I had to create a small script that could easily get the list of packages currently distributed to a select DP and assign that same list again to the same or other DP.

This is especially useful if you have a DP that’s giving you problems, usually what I do is to delete it and reinstall it again from the console, the only problem with that is that you have to redistribute all the content to it through the network and know which packages were distributed to that DP.

If you’re lucky, you have all distributed content to DP groups, so you just need to only add it back again to the same groups, still you need to make sure you don’t forget about which ones.

One interesting fact is that if by any chance you have a backup of the SccmContentLib folder you can actually reuse it and spare some network bandwidth.

If you set the DP you’re reinstalling as a Pull DP, it will check the SccmContentLib before actually requesting the content and if it’s there it will reuse it. And if you only use regular DP’s you can also set your DP as Pull DP just during this process until all the packages become available and afterwards set it back to a regular DP again.

This is only possible when using a Pull DP, so that all the processing is done at the DP side otherwise, for a regular DP, it will always send the content.

If you only use regular DP’s you can also set your DP as Pull DP just during this process until all the packages become available and afterwards set it back to a regular DP again.

While this is something easily done trough SQL or WMI, with Powershell being the new kid on the block with so many interesting to use cmdlets released to ConfigMgr 2012 I’ve decided to exclusively use Powershell.

Be advised that:

THIS SAMPLE CODE AND ANY RELATED INFORMATION ARE PROVIDED "AS IS" WITHOUT

WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT

LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS

FOR A PARTICULAR PURPOSE. 

This was created for sample purposes only and posted as a sample, you could use at as a basis for your own script but it's mandatory to change it to fit your needs and environment.

I’ve made it so you can set 2 different options:

# -GetDPinfo - This will get DP information before removing it from the console and add it to a CSV file

# -SetDPinfo - This will configure the DP with the previously captured information importing it from a CSV file

And you also need to specify the DP name’s, so at the end the full command line is :

Usage: RecoverDP <option> <DP_FQDN> 

You should use the option GetDPInfo when the DP is nonfunctional and before deleting it from the console.

After reinstalling the DP, run the script again with the –SetDPinfo option

For instance, if I run it in my lab:

 

And the file looks like this:

To assign this CSV file list of packages to a DP you just need run:         

 

 If the packages were already there, you get the Warning above but it’s safe to proceed.

Everytime you run it with the option –setdpinfo you get this confirmation box:

This should help you out recovering some DP’s.

If you’re interested in Disaster Recovery scenarios for all the different roles in ConfigMgr and the entire hierarchy stay tuned as we’re currently working on some really great stuff for our Premier customers!

Cheers

RecoverDP.ps1