PowerShell script exchange
Post Reply
Andreas Neufert
VP, Product Management
Posts: 6748
Liked: 1408 times
Joined: May 04, 2011 8:36 am
Full Name: Andreas Neufert
Location: Germany
Contact:

Add Networkmappings to Replica (v8 and newer)

Post by Andreas Neufert » 2 people like this post

Hi Team,

just a small example for the new v8 functionallity round about setting network mappings.
This code is not compatible with v7 and older.

Code: Select all

#Input
$JobName = "Test-replication"
$SourceManagedServer = "esxi55u1" #Veeam reads network objects here
$SourceNetworks = @(“MGMT”,"DMZ”)
$TargetManagedServer = "esxi55u1"  #Veeam reads network objects here
$TargetNetworks = @("LAN","LAN")

#Load Veeam Plugin
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue

#Create arraylist and place all SourceNetwork Objects there
$SourceNetworkObjects = New-Object System.Collections.ArrayList
Foreach($SourceNetwork in $SourceNetworks) {
$snetwork = Get-VBRServer -Name $SourceManagedServer | Get-VBRViServerNetworkInfo | where {$_.Name -eq $SourceNetwork}
$SourceNetworkObjects.add($snetwork);
}

#Create arraylist and place all TargetNetwork Objects there
$TargetNetworkObjects = New-Object System.Collections.ArrayList
Foreach($TargetNetwork in $TargetNetworks) {
$tnetwork = Get-VBRServer -Name $TargetManagedServer | Get-VBRViServerNetworkInfo | where {$_.Name -eq $TargetNetwork}
$TargetNetworkObjects.add($tnetwork);
}

#Read out the Jobobject
$JobObject = Get-VBRJob -Name $JobName
#Write the network list to the job
Set-VBRViReplicaJob -job $JobObject -EnableNetworkMapping -SourceNetwork $SourceNetworkObjects -TargetNetwork $TargetNetworkObjects
Post Reply

Who is online

Users browsing this forum: No registered users and 27 guests