Add Networkmappings to Replica (v8 and newer)

PowerShell script exchange

Add Networkmappings to Replica (v8 and newer)

Veeam Logoby Andreas Neufert » Wed Mar 18, 2015 9:49 am 1 person likes 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
Andreas Neufert
Veeam Software
 
Posts: 2200
Liked: 360 times
Joined: Wed May 04, 2011 8:36 am
Location: Germany
Full Name: @AndyandtheVMs Veeam PM

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests