Code: Select all
Connect-VBRServer
Connect-VIServer vcenter -Credential
$CDPPolicy = Get-VBRCDPPolicy -Name "CDP"
$SourceServer = Get-VBRServer -Type ESXi -Name 'dc1-esx'
$SourceNetwork = Get-VBRViServerNetworkInfo -Server $SourceServer
$TargetServer = Get-VBRServer -Type ESXi -Name 'dc2-esx'
$TargetNetwork = Get-VBRViServerNetworkInfo -Server $TargetServer |Where-Object{$_.NetworkName -like 'DRP*'}
$AllmyObject = @()
foreach($t in $TargetNetwork){
$Name = $t.NetworkName.ToString().Substring(4)
$s = $SourceNetwork | Where-Object{$_.NetworkName -like "$Name"}
if(($null -ne $s) -and ($s.NetworkName -notlike '*TRUNK*')){
$myObject = [PSCustomObject]@{
SourceNetwork = $s
TargetNetwork = $t
}
$AllmyObject += $myObject
}
}
$VBRCDPPolicyArg = @{
Policy = $CDPPolicy
SourceNetwork = $AllmyObject.SourceNetwork
TargetNetwork = $AllmyObject.TargetNetwork
}
Set-VBRCDPPolicy @VBRCDPPolicyArg
Set-VBRCDPPolicy : Unable to validate network mapping configuration: the same network Source network: DC1-DVS-Workloads is specified as source and target
At line:1 char:1
+ Set-VBRCDPPolicy @VBRCDPPolicyArg
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-VBRCDPPolicy], Exception
+ FullyQualifiedErrorId : System.Exception,Veeam.Backup.PowerShell.Cmdlets.SetVBRCDPPolicy