PowerShell script exchange
Post Reply
QoX8x
Service Provider
Posts: 7
Liked: 1 time
Joined: Aug 10, 2021 2:02 pm
Contact:

Start-VBRHvRestoreVM Specify Hyper-V Switch

Post by QoX8x »

Hi Guys,

When restoring a server using the UI it lets you select the Hyper-V virtual switch you want to attach the restored VM to. I can't seem to find any reference in the doc on how to do this.

I have seen Get-VBRHvServerNetworkInfo and that lets me see the switch but no way to set it.

Any ideas?

Case #04958873
Mildur
Product Manager
Posts: 8735
Liked: 2294 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Start-VBRHvRestoreVM Specify Hyper-V Switch

Post by Mildur » 1 person likes this post

I don‘t find it either.
You could use as a workaround a hyperv command to connect the vm to a virtual switch after restoring the vm. Something like that:

https://docs.microsoft.com/en-us/powers ... ver2019-ps

Code: Select all

Get-VMNetworkAdapter -VMName Test1 | Connect-VMNetworkAdapter -SwitchName InternetAccess
Product Management Analyst @ Veeam Software
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Start-VBRHvRestoreVM Specify Hyper-V Switch

Post by oleg.feoktistov »

Hi @QoX8x,

Currently there is no way to specify virtual switch during Hyper-V Entire VM Restore through PS.
The workaround would be to connect network adapters after restore as Fabian showed above.

Thanks,
Oleg
QoX8x
Service Provider
Posts: 7
Liked: 1 time
Joined: Aug 10, 2021 2:02 pm
Contact:

Re: Start-VBRHvRestoreVM Specify Hyper-V Switch

Post by QoX8x »

All my VM's connect to the same switch, so I was using

Code: Select all

get-vm | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName "Switch01"
It's just a bit of a pain when all my VM NIC's are on different VLAN's.

Thank you for your help.
Mildur
Product Manager
Posts: 8735
Liked: 2294 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Start-VBRHvRestoreVM Specify Hyper-V Switch

Post by Mildur »

Glad it helped :)
Yes, it could be a pain.

You could filter the name of the adapter in the output of the Get-vmnetworkadapter command, if you have multiple vlan/switches.
Product Management Analyst @ Veeam Software
Post Reply

Who is online

Users browsing this forum: No registered users and 18 guests