Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
# Please Specify The FQDN or IP address of your DPM Server
# DSConfig.ps1
$infoText = "This script will generate the DatasourceGroups.xml file in the current path. Once this file is created merge it with the same file name under %programfiles%\Microsoft DPM\DPM\Config directory on the DPM server. Read the documentation for more details."
echo $infoText
$header = "<?xml version=`"1.0`" encoding=`"utf-16`"?> `n <DatasourceGroup xmlns:xsi=`"`" xmlns:xsd=`"`" xmlns=`"`">"
$footer = "</DatasourceGroup>"
import-module -name FailoverClusters
$dir = [guid]::NewGuid()
md $dir
$cluster = get-Cluster
$FQDN = $cluster.Name + "." + $cluster.Domain
$res = get-clusterresource | where-object { $_.ResourceType.Name -eq "Virtual Machine Configuration"}
foreach ($r in $res)
$VmObj = Get-ClusterParameter -inputobject $r | where {$_.Name -eq "VmStoreRootPath"} # Identifies the CSV volume on which the VM is hosted.
$VmName = Get-ClusterParameter -inputobject $r | where {$_.Name -eq "VmId"}
$vol = $vmobj.Value.Split("\")[2] # $vol will return to us the Volume<number> of the CSV on which the VM resides.
$line = "<Datasource DatasourceName=`"" + $VmName.Value +"`"" + " ProtectedServerName=`"" + $r.OwnerGroup.Name + "."+ $FQDN +"`"" + " WriterId=`"66841cd4-6ded-4f4b-8f17-fd23f8ddc3de`" />"
echo $line >> $dir\$vol # File VolumeX will contain entries for all VMs hosted on CSV VolumeX
echo $header > DataSourceGroups.xml
$filelist = dir $dir\Volume*
$GroupEndString = "</Group>"
foreach ($file in $filelist)
$GroupBeginString = "<Group GroupName=`"" + $file.Name + "-" + $FQDN + "`">" # Group name is kept VolumeX itself
echo $GroupBeginString >> DataSourceGroups.xml
type $file >> DataSourceGroups.xml # Consolidating groups pertaining to all the volumes.
echo $GroupEndString >> DataSourceGroups.xml
Remove-Item -Force -Recurse $dir
echo $footer >> DataSourceGroups.xml
# Copy The DataSourceGroups.xml file to the DPM Server
copy DataSourceGroups.xml \\$DPMServerName"\DPMConfig"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment