This is one of the first post of a short blog series with some simple PowerShell scripts and oneliners for Hyper-V. One this is how you can connect a Virtual Network Adapter of a Hyper-V Virtual Machine to another Virtual Switch.
This is very simple, with this command you can see all the Network Adapters of the Virtual Machine and to which Switch they are connected:
Get-VM "VM01" | Get-VMNetworkAdapter
With this command you can connect it to another Switch:
Get-VM "VM01" | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName "NewSwitch"
Now of course you can also do this for all Virtual Machines running on a Hyper-V host:
Get-VM | Get-VMNetworkAdapter Get-VM | Get-VMNetworkAdapter | Connect-VMNetworkAdapter -SwitchName "NewSwitch" Get-VM | Get-VMNetworkAdapter
Just wanted to say thanks Thomas! Exactly what I needed to point me in the right direction. In my case, I wanted to apply a switch to all of my VMs adapters (not just one) so I just left out the VM name.
Thank you Dave, great that this blog helped you!