Hi folks,
I've been trying to script out the process of creating a replication job and I've managed to get through all the areas where people have had trouble before, however i'm stuck with the network piece. My VMs are using 2x network adaptors and both use separate networks. When I specify (as the user guide says) both portgroups with a comma in between, the first network/portgroup that is specified gets used for all network adaptors and the other portgroups that i specified get ignored.
Here is my script:
$JobList = import-csv -Path .\Documents\VMReplicas.csv -Delimiter "`t" Foreach($i in $JobList){ $SourceVMNum = $i.SourceVM $SourceVMName = (Get-InventoryEntity | Where {$_.Name -match "^$SourceVMNum"}).Name $CreateDateTime = get-date -Format "M/dd/yyyy hh:mm:ss tt" $SourceVMEntity = (Get-InventoryEntity | Where {$_.Name -match "^$SourceVMNum"}) $StartDate = get-date -uFormat "%Y-%m-%d" $StartTime = $i.Time.Substring(0,$i.Time.Length-3) $Schedule = (New-IntervalSchedule -StartTime "$StartDate $StartTime" -IntervalHours 4) $targetHost = $i.TargetHost $TargetHostEntity = (Get-InventoryEntity | where {$_.Name -match $targethost}) $TargetVM = $i.TargetVM $TargetNetwork1 = $i.NetworkName1 $TargetDatastore = $i.TargetDatastore IF($i.NetworkName3 -like $NULL){ $TargetNetwork2 = $i.NetworkName2 Add-replicationjobtemplate -JobName "Replicate '$SourceVMName'" -JobDescription "Replication Job Template Description $datetime" -JobEntity $SourceVMEntity -TargetHost $TargetHostEntity -ReplicateName $TargetVM -Type Differential -TargetNetworks $TargetNetwork1, $TargetNetwork2 -PrimaryDatastore $TargetDatastore -TargetDatastores $TargetDatastore -JobSchedule $Schedule -Flags 'CheckDestinationFreeSpace, UpdateNotes' }ELSE{$TargetNetwork2 = ($i.NetworkName2) $TargetNetwork3 = ($i.NetworkName3) Add-replicationjobtemplate -JobName "Replicate '$SourceVMName'" -JobDescription "Replication Job Template Description $datetime" -JobEntity $SourceVMEntity -TargetHost $TargetHostEntity -ReplicateName $TargetVM -Type Differential -TargetNetworks $TargetNetwork1, $TargetNetwork2, $TargetNetwork3 -PrimaryDatastore $TargetDatastore -TargetDatastores $TargetDatastore -JobSchedule $Schedule -Flags 'CheckDestinationFreeSpace, UpdateNotes' } }
Am I specifying the networks incorrectly ? I have even tried running the script with the $targetnetwork1, $targetnetwork2 swapped out for the Portgroup names, having no space in between the comma, putting in "Quotes" , but nothing seems to make it work.
I am coming to the conclusion that the API doesnt support multiple networks being sent to it, even though the guide says
"
•
|
"
Thanks,
Matt