This is for VMware replications from a distributed vSwitch to a standard vSwitch.
(I guess standard to standard works if the names are the same)
1 issue I found with this script is that the VMs associated for the job can change. If you removed VMs from a job and then run this script, the removed ones will appear again.
I let VMware know about that issue in a ticket.
There is lots of cleanup that could be done to the arrays with loops. This just got the job done for me (otherwise I would have had over 1000 clicks in the GUI)
Code: Select all
asnp "VeeamPSSnapIn" -ErrorAction SilentlyContinue
$JobName = "Test_Repl"
#Map Source to Destination VMware network names
$srcVLAN0 = "VLAN2100-IT_RDS"
$dstVLAN0 = "VLAN2100-IT_RDS"
$srcVLAN1 = "VLAN2101-IT_Monitoring"
$dstVLAN1 = "VLAN2101-IT_Monitoring"
$srcVLAN2 = "VLAN2102-IT_Prod"
$dstVLAN2 = "VLAN2102-IT_Prod"
$srcVLAN3 = "VLAN2103-IT_Test"
$dstVLAN3 = "VLAN2103-IT_Test"
$srcVLAN4 = "VLAN2110-Intranet_Prod"
$dstVLAN4 = "VLAN2110-Intranet_Prod"
$srcVLAN5 = "VLAN2111-Intranet_Test"
$dstVLAN5 = "VLAN2111-Intranet_Test"
$srcVLAN6 = "VLAN0001-Prod"
$dstVLAN6 = "DR_ReplVMs"
$srcVLAN7 = "VLAN0999-DMZ"
$dstVLAN7 = "DR_DMZ"
$job = Get-VBRJob -Name $JobName
#Source Network is a distributed switch
#Destination networks are standard switch
$srcNet0 = Get-VBRViServerNetworkInfo -Server "hq-esx1.corp.com" | Where { $_.Type -eq "ViDVS" -and $_.SwitchName -eq "HQ-DSwitch" -and $_.NetworkName -eq $srcVLAN0 }
$dstNet0 = Get-VBRViServerNetworkInfo -Server "dr-esx1.corp.com" | Where-Object { $_.NetworkName -eq $dstVLAN0 }
$srcNet1 = Get-VBRViServerNetworkInfo -Server "hq-esx1.corp.com" | Where { $_.Type -eq "ViDVS" -and $_.SwitchName -eq "HQ-DSwitch" -and $_.NetworkName -eq $srcVLAN1 }
$dstNet1 = Get-VBRViServerNetworkInfo -Server "dr-esx1.corp.com" | Where-Object { $_.NetworkName -eq $dstVLAN1 }
$srcNet2 = Get-VBRViServerNetworkInfo -Server "hq-esx1.corp.com" | Where { $_.Type -eq "ViDVS" -and $_.SwitchName -eq "HQ-DSwitch" -and $_.NetworkName -eq $srcVLAN2 }
$dstNet2 = Get-VBRViServerNetworkInfo -Server "dr-esx1.corp.com" | Where-Object { $_.NetworkName -eq $dstVLAN2 }
$srcNet3 = Get-VBRViServerNetworkInfo -Server "hq-esx1.corp.com" | Where { $_.Type -eq "ViDVS" -and $_.SwitchName -eq "HQ-DSwitch" -and $_.NetworkName -eq $srcVLAN3 }
$dstNet3 = Get-VBRViServerNetworkInfo -Server "dr-esx1.corp.com" | Where-Object { $_.NetworkName -eq $dstVLAN3 }
$srcNet4 = Get-VBRViServerNetworkInfo -Server "hq-esx1.corp.com" | Where { $_.Type -eq "ViDVS" -and $_.SwitchName -eq "HQ-DSwitch" -and $_.NetworkName -eq $srcVLAN4 }
$dstNet4 = Get-VBRViServerNetworkInfo -Server "dr-esx1.corp.com" | Where-Object { $_.NetworkName -eq $dstVLAN4 }
$srcNet5 = Get-VBRViServerNetworkInfo -Server "hq-esx1.corp.com" | Where { $_.Type -eq "ViDVS" -and $_.SwitchName -eq "HQ-DSwitch" -and $_.NetworkName -eq $srcVLAN5 }
$dstNet5 = Get-VBRViServerNetworkInfo -Server "dr-esx1.corp.com" | Where-Object { $_.NetworkName -eq $dstVLAN5 }
$srcNet6 = Get-VBRViServerNetworkInfo -Server "hq-esx1.corp.com" | Where { $_.Type -eq "ViDVS" -and $_.SwitchName -eq "HQ-DSwitch" -and $_.NetworkName -eq $srcVLAN6 }
$dstNet6 = Get-VBRViServerNetworkInfo -Server "dr-esx1.corp.com" | Where-Object { $_.NetworkName -eq $dstVLAN6 }
$srcNet7 = Get-VBRViServerNetworkInfo -Server "hq-esx1.corp.com" | Where { $_.Type -eq "ViDVS" -and $_.SwitchName -eq "HQ-DSwitch" -and $_.NetworkName -eq $srcVLAN7 }
$dstNet7 = Get-VBRViServerNetworkInfo -Server "dr-esx1.corp.com" | Where-Object { $_.NetworkName -eq $dstVLAN7 }
#Create array of source and then dest. network objects
$arrSrc = $srcNet0, $srcNet1, $srcNet2, $srcNet3, $srcNet4, $srcNet5, $srcNet6, $srcNet7
$arrDst = $dstNet0, $dstNet1, $dstNet2, $dstNet3, $dstNet4, $dstNet5, $dstNet6, $dstNet7
#update the job with array of source and array of dest. networks
Set-VBRViReplicaJob -Job $job -EnableNetworkMapping -SourceNetwork $arrSrc -TargetNetwork $arrDst