Solved

PowerShell Start-VBRRestoreVM -TargetNetwork


Userlevel 5
Badge

Hi,

I am useing PowerShell doing VM Restores. It works pretty well. The only thing, that is not working for me, is to place the Target Network. I am restoreing VMs in an different target. 

If I understand the documentation correct, I need to Get the ViServerNetwork Info from my host. So I put this information in a varible like this:

$target = Get-VBRViServerNetworkInfo -Server "srv01.veeam.local" | Where-Object { $_.NetworkName -eq "NW01" }

But putting this varible to the Start command, the restore process will fail because auf the -TargetNetwork. So what I am doing wrong? 

Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server –ResourcePool $rpool –Datastore $datastore –PowerUp $true -TargetNetwork $target

icon

Best answer by Hartmut 4 October 2021, 08:21

View original

21 comments

Userlevel 7
Badge +6

I'm not sure about this, but do you also have to add the SourceNetwork parameter?

SourceNetwork

For restore to another location.

Specifies the source site network. Veeam Backup & Replication will map it to the target network.

False

Named

False

False

TargetNetwork

For restore to another location.

Specifies the target site network. Veeam Backup & Replication will map it with the source network.

Userlevel 7
Badge +7

Never tried this before. But I would check the $target-object. Is it the object-type (VBRViNetworkInfo) you need? Maybe it is a array insteat of a single object? and what is the exact error-message?

Userlevel 5
Badge

Never tried this before. But I would check the $target-object. Is it the object-type (VBRViNetworkInfo) you need? Maybe it is a array insteat of a single object? and what is the exact error-message?

 I tried both. I just used the variable, in my testing $network also tried to use it as array “$network.Name”  for example. Script ist woring fine without -TargetNetwork.  

 

Picture 1: $network.Name

 

 

 

Picture 2: $network

 

Userlevel 5
Badge

Never tried this before. But I would check the $target-object. Is it the object-type (VBRViNetworkInfo) you need? Maybe it is a array insteat of a single object? and what is the exact error-message?

That is the error message When I am using just the variable:

 

Thats the error Message, when I am choosing one single objcet. $network.Name for example. I get the same error message form any kind of objects that I can choose. 

 

 

And yes, I guess VBRViNetworkInfo[] is needed, when I understand the documentation correctly.

Userlevel 5
Badge

Never tried this before. But I would check the $target-object. Is it the object-type (VBRViNetworkInfo) you need? Maybe it is a array insteat of a single object? and what is the exact error-message?

 

I am confused, last posts gone wrong. Hopefully this one will work.

So when I understand the docu correctly I need VBRViNetworkInfo[].

I get different errors useing the variable or one item from the array. See both screenshots.

Userlevel 7
Badge +7

can you run $network.gettype() and show the answer?

Userlevel 5
Badge

can you run $network.gettype() and show the answer?

 

Userlevel 7
Badge +7

object type seems to be correct. In a screenshot I just saw you wrote $network.name as parameter. This is definitely wrong, because this will be a string-type. You need to replace be $network only.

The other screenshot shows the error error in parameter source.

Userlevel 5
Badge

object type seems to be correct. In a screenshot I just saw you wrote $network.name as parameter. This is definitely wrong, because this will be a string-type. You need to replace be $network only.

The other screenshot shows the error error in parameter source.

 

Thanks for your answers :-)

But useing only $network will not work. The greenline is, whats in the varaible $network. The Start-VBRRestoreVM Task is working fine, without -TargetNetwork $network  

 

I guess I need to enter a -SorceNetwork $sourcenetwork as well. Thats why he is asking for source. So how do I get the source network from the backup file? I quess than I have anything I need.

 

 

Userlevel 7
Badge +7

Just read the source network like the target network. so the task will map the specified source network to the specified target network. 

Userlevel 5
Badge

Just read the source network like the target network. so the task will map the specified source network to the specified target network. 

That’s the challenge. The use case is disaster recovery.

There is no source network anymore. It’s a direct vm recovery from s3 to vmware cloud on aws.  

I will try to rebuild the network in the destination an use it as „source“ maybe that’s working. I will report. 
Thx so far

Userlevel 5
Badge

Ok, I could resolve the problem. 

So you have to give the -TargetNetwork AND the -SourceNetwork

If your Source environment is destroyed, as it is during disaster, you need to create a dummy-network in the target vCenter. The network doesn´t matter. The name, should be the same, like in the source site. 

 

Step 1:  Create a Dummy Network in the Target vCenter to use it for the -SourceNetwork

Step 2: Put this network in a variable

$sorce_network = Get-VBRViServerNetworkInfo -Server “YOUR HOST” | Where-Object { $_.NetworkName -eq "Dummy Source Network

Step 3: Get your Target Network

$target_network = Get-VBRViServerNetworkInfo -Server “YOUR HOST” | Where-Object { $_.NetworkName -eq "Target Network

 

Step 4: Start your Restore and have Fun :-) :

Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server –ResourcePool $rpool –Datastore $datastore –PowerUp $true -SourceNetwork $source_network -TargetNetwork $target_network

Userlevel 7
Badge +6

Hi @Hartmut,

 

I’d need to validate this in the lab but when you back up your VMs, Veeam would learn the source network information, this is handy in scenarios whereby you have multiple NICs such as a DMZ and a LAN interface so you can change the correct one.

 

I wouldn’t expect the source network to still have to exist, because as you say, in a DR this network may no longer exist.

 

If I get some time to lab this I’ll report back my findings by backing up a VM with a port group and then delete the port group.

Userlevel 5
Badge

Hi @Hartmut,

 

I’d need to validate this in the lab but when you back up your VMs, Veeam would learn the source network information, this is handy in scenarios whereby you have multiple NICs such as a DMZ and a LAN interface so you can change the correct one.

 

I wouldn’t expect the source network to still have to exist, because as you say, in a DR this network may no longer exist.

 

If I get some time to lab this I’ll report back my findings by backing up a VM with a port group and then delete the port group.

 

It would be great If you could find an easier way. 

During my testing a vailid source network was needed. The name of the portgroup must equal the name of the source network from the vm in the backupfile. Veeam puts an array of networking informationes in the variable. So just entering the name for -SourceNetwork will not work too. 

 

Userlevel 7
Badge +6

If you restore via the GUI the source network is populated automatically. So, a source network has to be given.

I think it is implemented this way to be sure to catch the correct network on the VM when there is more than one network defined. And yes, the existing network could be the default for this command if there is one network only.

Userlevel 7
Badge +6

Thanks for posting the solution @Hartmut. The documentation isn't that clear about both parameters; at least my guesswasn't that wrong😅

But what happens if you have multiple networks in a VM? How would those match with only a single network parameter?

Userlevel 7
Badge +6

😀 perhaps you can specify several source and target network pairs?

Userlevel 7
Badge +7

Ok, I could resolve the problem. 

So you have to give the -TargetNetwork AND the -SourceNetwork

If your Source environment is destroyed, as it is during disaster, you need to create a dummy-network in the target vCenter. The network doesn´t matter. The name, should be the same, like in the source site. 

 

Step 1:  Create a Dummy Network in the Target vCenter to use it for the -SourceNetwork

Step 2: Put this network in a variable

$sorce_network = Get-VBRViServerNetworkInfo -Server “YOUR HOST” | Where-Object { $_.NetworkName -eq "Dummy Source Network

Step 3: Get your Target Network

$target_network = Get-VBRViServerNetworkInfo -Server “YOUR HOST” | Where-Object { $_.NetworkName -eq "Target Network

 

Step 4: Start your Restore and have Fun :-) :

Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server –ResourcePool $rpool –Datastore $datastore –PowerUp $true -SourceNetwork $source_network -TargetNetwork $target_network

Thanks for your solution here!

 

Userlevel 5
Badge

Hi

thx to the great veeam support! There is a better way to get the source. 

  • $backup = Get-VBRBackup -name "xxx"
  • $rp = Get-VBRRestorePoint -Backup $backup | where xyz....
  • $Oibs = $backup.GetOibs()
  • $Nics = $Oibs.Auxdata.Nics
  • $source = $rp.Auxdata.Nics.Network

$source ist jetzt das Netzwerk des ausgewählten Restore Punktes aus dem Backup.

I could confirm his positive testing. Its working fine. 

Start-VBRRestoreVM –RestorePoint $rp –Server $server –ResourcePool $pool –Datastore $store -Folder $folder –PowerUp $true -SourceNetwork $source -TargetNetwork $target

 

 

 

Userlevel 7
Badge +6

With this approach you can get multiple networks, too.

But is it possible to give several networks to the Restore command?

Userlevel 7
Badge +7

Hi

thx to the great veeam support! There is a better way to get the source. 

  • $backup = Get-VBRBackup -name "xxx"
  • $rp = Get-VBRRestorePoint -Backup $backup | where xyz....
  • $Oibs = $backup.GetOibs()
  • $Nics = $Oibs.Auxdata.Nics
  • $source = $rp.Auxdata.Nics.Network

$source ist jetzt das Netzwerk des ausgewählten Restore Punktes aus dem Backup.

I could confirm his positive testing. Its working fine. 

Start-VBRRestoreVM –RestorePoint $rp –Server $server –ResourcePool $pool –Datastore $store -Folder $folder –PowerUp $true -SourceNetwork $source -TargetNetwork $target

 

 

 

Good to see this solution! It is quite easier, so you do not need to create dummy-networks in front. Thanks for updating your post!

Comment