-
- Service Provider
- Posts: 43
- Liked: 3 times
- Joined: Jul 21, 2022 10:40 pm
- Full Name: Matthew Boswell
- Contact:
Question about Start-VBRRestoreVM and multiple NICs
Hi,
I'm restoring VMware restore points to new locations with different networking config and am wondering how to handle multiple NICs on the source VM. Right now I can specify -SourceNetwork $restorepoint.Auxdata.Nics[0].Network to just connect the first one (if there's more than one) but I'd like to be able to handle the case where there's more than one element in $restorepoint.Auxdata.Nics. In the case of more than one NIC on the source I intend to connect them all to the same port group, so TargetNetwork will always be the same.
I'm restoring VMware restore points to new locations with different networking config and am wondering how to handle multiple NICs on the source VM. Right now I can specify -SourceNetwork $restorepoint.Auxdata.Nics[0].Network to just connect the first one (if there's more than one) but I'd like to be able to handle the case where there's more than one element in $restorepoint.Auxdata.Nics. In the case of more than one NIC on the source I intend to connect them all to the same port group, so TargetNetwork will always be the same.
-
- Veeam Software
- Posts: 2006
- Liked: 666 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Question about Start-VBRRestoreVM and multiple NICs
Hi Matthew,
What if you loop through the networks, add each of them to a new array and pass it to SourceNetwork parameter?
It accepts arrays, so should work in your case. And then for TargetNetwork you just specify the port group you want to connect restored vms to.
Thanks,
Oleg
What if you loop through the networks, add each of them to a new array and pass it to SourceNetwork parameter?
It accepts arrays, so should work in your case. And then for TargetNetwork you just specify the port group you want to connect restored vms to.
Thanks,
Oleg
-
- Service Provider
- Posts: 43
- Liked: 3 times
- Joined: Jul 21, 2022 10:40 pm
- Full Name: Matthew Boswell
- Contact:
Re: Question about Start-VBRRestoreVM and multiple NICs
When the restore point has multiple NICs the object is already an array:
I've tried passing $restorepoint.AuxData.Nics.Network as-is but get an Index error unless I select one specific element of the array as the argument.
I can either select one NIC like $restorepoint.AuxData.Nics[0].Network or select one network like $restorepoint.AuxData.Nics.Network[0]. Doesn't seem to matter.
Code: Select all
PS C:\Windows\system32> $restorepoint.AuxData.Nics.Network.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True Object[] System.Array
Code: Select all
Start-VBRRestoreVM : Index was outside the bounds of the array.
-
- Veeam Software
- Posts: 2006
- Liked: 666 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Question about Start-VBRRestoreVM and multiple NICs
At first I thought it's because an array of networks inside of a restore point is being presented as an array of a generic type (Object[]). And SourceNetwork & TargetNetwork don't seem to accept that. But it didn't work even with array conversion to VBRViNetworkInfo[].
Looks like a bug to me. I'll bring it up with QA and follow up here as soon as I have any updates.
Thanks!
Looks like a bug to me. I'll bring it up with QA and follow up here as soon as I have any updates.
Thanks!
-
- Service Provider
- Posts: 43
- Liked: 3 times
- Joined: Jul 21, 2022 10:40 pm
- Full Name: Matthew Boswell
- Contact:
Re: Question about Start-VBRRestoreVM and multiple NICs
I got it to work with an array. What I did was create a for loop to populate an array for -TargetNetwork that is the same length as the -SourceNetwork array.
It appears to map them by index.
It appears to map them by index.
Code: Select all
if ($restorepoint.AuxData.Nics.Length -gt 1)
{
$targetnetwork = @()
for ($i = 0; $i -lt $newest.AuxData.Nics.Length; $i++)
{
$targetnetwork += Get-VBRViServerNetworkInfo -Server $desthost | Where-Object NetworkName -eq "MyNetwork"
}
}
else
{
$targetnetwork = Get-VBRViServerNetworkInfo -Server $desthost | Where-Object NetworkName -eq "MyNetwork
}
-
- Service Provider
- Posts: 43
- Liked: 3 times
- Joined: Jul 21, 2022 10:40 pm
- Full Name: Matthew Boswell
- Contact:
Re: Question about Start-VBRRestoreVM and multiple NICs
For some reason I can't edit the above post but I meant to clean up the var names so they are a bit more readable.... Line 4 should be
Code: Select all
for ($i = 0; $i -lt $restorepoint.AuxData.Nics.Length; $i++)
-
- Veeam Software
- Posts: 2006
- Liked: 666 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Question about Start-VBRRestoreVM and multiple NICs
Hi Matthew,
Thanks for sharing. Just to clarify - did you pass an array of the same target networks to TargetNetwork parameter to match the array length of SourceNetwork? And it worked?
Best regards,
Oleg
Thanks for sharing. Just to clarify - did you pass an array of the same target networks to TargetNetwork parameter to match the array length of SourceNetwork? And it worked?
Best regards,
Oleg
-
- Service Provider
- Posts: 43
- Liked: 3 times
- Joined: Jul 21, 2022 10:40 pm
- Full Name: Matthew Boswell
- Contact:
Re: Question about Start-VBRRestoreVM and multiple NICs
That's exactly what I did and it worked.did you pass an array of the same target networks to TargetNetwork parameter to match the array length of SourceNetwork? And it worked?
Thanks,
Matt
-
- Veeam Software
- Posts: 2006
- Liked: 666 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Question about Start-VBRRestoreVM and multiple NICs
Checked the code, that's exactly what is happening. Then passing source & target network arrays of the same length even if some target networks are duplicated makes sense.It appears to map them by index.
Thanks!
Who is online
Users browsing this forum: No registered users and 7 guests