PowerShell script exchange
Post Reply
dsATspace
Influencer
Posts: 19
Liked: never
Joined: Feb 28, 2022 9:09 am
Full Name: dennis
Contact:

RStart-VBRRestoreVM: Restore with -TargetNetwork - fail

Post by dsATspace »

Hello;

I like to use "-TargetNetwork" with Start-VBRRestoreVM

But it fail

Image

I fill the variable:

Code: Select all

$targetNet = Get-VBRViServerNetworkInfo -Server $dstvCenter | Where-Object { $_.NetworkName -eq "MyDummyNet" }

Code: Select all

PS C:\scripts> $net=Get-VBRViServerNetworkInfo -Server "192.168.1.130" | Where-Object { $_.NetworkName -eq "MyDummyNet" }
PS C:\scripts> $net


NetworkName : MyDummyNet
Id          : MyDummyNet
Name        : MyDummyNet
Path        : MyDummyNet
Type        : ViSimple
NetworkId   :
ViReference : network-26
Mildur
Product Manager
Posts: 9848
Liked: 2606 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: RStart-VBRRestoreVM: Restore with -TargetNetwork - fail

Post by Mildur »

Hi Dennis

You don‘t have filled any variable. Many are missing. That‘s why you see the error, that no source was provided. Veeam doesn‘t know what to restore and where to.
- restore point
- server
- ressource Pool
- folder
- Datastore

First, you have to get this objects and save them in a variable. Then they can be used with the restore command.

Please follow the example 2 in this guide. It will help you to get all parameters correct.

For the networkname, I think you can use directly the network name as it‘s written, without to save it first to a variable. If you use targetnetwork, you must also use sourcenetwork.

Code: Select all

 $restorepoint = Get-VBRRestorePoint
$server = Get-VBRServer -Name "north.support.local"
$rpool = Find-VBRViResourcePool -Server $server -Name „RessourcePoolName“
$datastore = Find-VBRViDatastore -Server $server -Name „DatastoreName“
Start-VBRRestoreVM –RestorePoint $restorepoint[1] –Server $server –ResourcePool $rpool –Datastore $datastore –SourceNetwork „SourceNetworkName - TargetNetwork „myDummyNet“
Let me know if it works. If not, i‘ll happy to give it a try in my lab.
Product Management Analyst @ Veeam Software
dsATspace
Influencer
Posts: 19
Liked: never
Joined: Feb 28, 2022 9:09 am
Full Name: dennis
Contact:

Re: RStart-VBRRestoreVM: Restore with -TargetNetwork - fail

Post by dsATspace »

@Mildur

thanks!

my restore command work

I wanna add now the -TargetNet that I can choose in the target vCenter where the VM is restored
beacuse the VM is backuped on another veeam and vCenter.

$targetNet = Get-VBRViServerNetworkInfo -Server $dstvCenter | Where-Object { $_.NetworkName -eq "MyDummyNet" }


this command work:

Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server –ResourcePool $rpool –Datastore $datastore -folder $folder –PowerUp $false


but this did not work:

Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server –ResourcePool $rpool –Datastore $datastore -folder $folder -TargetNetwork $targetNet –PowerUp $false
Mildur
Product Manager
Posts: 9848
Liked: 2606 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: RStart-VBRRestoreVM: Restore with -TargetNetwork - fail

Post by Mildur »

Can you try to use:

Code: Select all

$SourceNetwork = Get-VBRViServerNetworkInfo -Server $server | Where-Object {$_.Networkname -eq "Original Network"}
$TargetNetwork = Get-VBRViServerNetworkInfo -Server $server | Where-Object {$_.Networkname -eq "New Network"}

Start-VBRRestoreVM –RestorePoint $restorepoint –Server $server –ResourcePool $rpool –Datastore $datastore -folder $folder -SourceNetwork $SourceNetwork -TargetNetwork $TargetNetwork –PowerUp $false
You must use SourceNetwork, when you use the parameter TargetNetwork. This statement is in the guide I provided in my last answer.
You can find Source Network Name and Target Network Name when you try to restore vm with the GUI. The names are listed in the network step. But I‘m not sure how it will work on powershell if you can‘t use Get-VBRViServerNetworkInfo to get the networks without access to the old infrastructure.
Product Management Analyst @ Veeam Software
dsATspace
Influencer
Posts: 19
Liked: never
Joined: Feb 28, 2022 9:09 am
Full Name: dennis
Contact:

Re: RStart-VBRRestoreVM: Restore with -TargetNetwork - fail

Post by dsATspace »

@mildur

may I used the wrong command ?!

Ok ist there a command to change the Network from a RestoredVM ?

For example the Network of the Backuped VM was: VM_Network and I wanna change it to "MyDummyNet" in the restored VM.
Mildur
Product Manager
Posts: 9848
Liked: 2606 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: RStart-VBRRestoreVM: Restore with -TargetNetwork - fail

Post by Mildur »

After the restore, veeam cannot change the network to another one.
But you can use vPowerCLI for that after you restored the VM to the new ESXI Host.

Set-NetworkAdapter lets you change the portgroup of an existing network adapter.
Product Management Analyst @ Veeam Software
dsATspace
Influencer
Posts: 19
Liked: never
Joined: Feb 28, 2022 9:09 am
Full Name: dennis
Contact:

Re: RStart-VBRRestoreVM: Restore with -TargetNetwork - fail

Post by dsATspace »

thank you!


$vm = vm1
$targetNetwork = MyDummyNet

Get-VM -Name $vm | Get-NetworkAdapter | Set-NetworkAdapter -NetworkName $targetNetwork -Confirm:$false
Post Reply

Who is online

Users browsing this forum: masahide.k and 14 guests