This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

vRanger Powershell API - Creating Replication Job Templates

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
"

TargetNetworks [<String>]: Networks to use on the target host. Separate multiple values with commas.

"

Thanks,
Matt

Parents
  • Hello Matt, 

    I believe you are doing it the right way. The parameter is expecting a string, not an entity, so I would believe that this is a defect. I'm personally handling that case and have raised it with development for further investigation. I can reproduce it locally with a brand new script I made. 

  • Following up this thread, R&D has confirmed that this is a defect (VR-911). It also happens if you try to update the replication job with the Update-ReplicationJobTemplate command. It should be fixed in the next release. 

Reply Children
No Data