I am using the script from DPM 2010. PowerShell Script to auto protect VMs as they get added to a CSV Cluster | Cloudtidings.com to auto add new VM’s to my DPM Protection Group.
I need to have a list of VM’s to exclude from being auto added to the group.
Outside this section
foreach ($ds in $unprotectedDSList)
{
write-host “Adding data source” $ds.Name “to” $MPG.FriendlyName
$npg = Add-ChildDatasource -ProtectionGroup $MPG -ChildDatasource $ds
# 12.1 Disk Allocation is skipped in case of short term protection being to tape.
if($MPG.protectionmethod -eq $tape) {continue;}
$x = Get-DatasourceDiskAllocation -Datasource $ds
Set-DatasourceDiskAllocation -Datasource $ds -ProtectionGroup $MPG
}
I need to have a list of servers (something like $VMsToIgnore = @(“SQL01”, “EXCH01”)) and test them against $ds.Name within the loop to see if there’s a match. The trouble is that $ds.Name may be “Offline\EXCH01” or “Online\EXCH01” so I can’t do a direct -compare against my list.
How would I do the check?