How to delete network mapping from replication job

PowerShell script exchange

How to delete network mapping from replication job

Veeam Logoby snzhang2 » Thu Feb 02, 2017 7:40 pm

I need to change the network mapping for replication jobs and what I find is that if the source and destination network are on standard switches the Set-VBRViReplicaJob cmdlet can't update an existing mapping. This is not a problem for distributed switches. But if there is no existing mapping it all goes as expected.

So what I thought is to remove the existing network mapping and then remap it. But I can't find a way to remove the network mapping using the existing cmdlets. I tried (set-VBRViReplicaJob -enablenetworking:$false -Job $job) and it actually deleted the source VM from the job.

Also if there is a way to get the existing network mapping that would be nice. This will help identify if the replication job network mapping is correct or not.

Thanks in advance.
snzhang2
Influencer
 
Posts: 22
Liked: 1 time
Joined: Wed Oct 12, 2016 3:17 pm
Full Name: Nan Zhang

Re: How to delete network mapping from replication job

Veeam Logoby v.Eremin » Fri Feb 03, 2017 11:20 am

I'm wondering what particular error you got while trying to set new mapping rules with the use of SourceNetwork and TargetNetwork parameters.
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: How to delete network mapping from replication job

Veeam Logoby snzhang2 » Fri Feb 03, 2017 6:24 pm

The command:

Code: Select all
Set-VBRViReplicaJob -Job $job  -SourceNetwork $srcVBRNetwork -TargetNetwork $trgVBRNetwork -EnableNetworkMapping


runs to completion without any error (return code via $? is True). But the TargetNetwork doesn't get updated as expected.

Nan
snzhang2
Influencer
 
Posts: 22
Liked: 1 time
Joined: Wed Oct 12, 2016 3:17 pm
Full Name: Nan Zhang

Re: How to delete network mapping from replication job

Veeam Logoby v.Eremin » Mon Feb 06, 2017 11:18 am

Can you also share the portion where source and target networks get assigned to variables?
v.Eremin
Veeam Software
 
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: How to delete network mapping from replication job

Veeam Logoby tsightler » Mon Feb 06, 2017 2:19 pm

I've run into this before. Here's a small example of code I use which wipes the existing mapping and saves that to the job just prior to setting the new mapping.

Code: Select all
# Remove the current NetworkMappings node if it already exist (possible bug)
if ($job.Options.Options.RootNode.NetworkMappings) {
    $job.Options.Options.RootNode.RemoveChild($job.Options.Options.RootNode.SelectSingleNode("//NetworkMappings"))
}
Set-VBRJobOptions -Job $job -Options $job.Options

# Set the new mapping
Set-VBRViReplicaJob -Job $job -EnableNetworkMapping -SourceNetwork $src_net_map -TargetNetwork $tgt_net_map
tsightler
Veeam Software
 
Posts: 4768
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: How to delete network mapping from replication job

Veeam Logoby snzhang2 » Wed Feb 08, 2017 4:11 pm

Thanks! That's exactly what I am after.

Unfortunately this code has the side effect of removing any existing VM mapping as well. Not sure why this would be the case as the the line for removing the mapping refers to "//NetworkMappings".
snzhang2
Influencer
 
Posts: 22
Liked: 1 time
Joined: Wed Oct 12, 2016 3:17 pm
Full Name: Nan Zhang

Re: How to delete network mapping from replication job

Veeam Logoby tsightler » Wed Feb 08, 2017 5:25 pm

I think this might be a bug in Set-VBRJobOptions, but I believe you can save them and remap easily enough, although I can't seem to dig up my example code for that.
tsightler
Veeam Software
 
Posts: 4768
Liked: 1737 times
Joined: Fri Jun 05, 2009 12:57 pm
Full Name: Tom Sightler

Re: How to delete network mapping from replication job

Veeam Logoby snzhang2 » Thu Feb 09, 2017 6:59 pm

I have a script to map VM replicas (taken from this forum and modified to my needs) so the work-around now would be to perform the network mapping first and then the VM replica mapping after.

Thanks again!
snzhang2
Influencer
 
Posts: 22
Liked: 1 time
Joined: Wed Oct 12, 2016 3:17 pm
Full Name: Nan Zhang


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 7 guests