Hyper-V Powershell

Get the name of the vSwitch used by all the VMs on a host:

Get-VM -ComputerName <hyper-v hostname> | where state -eq running | select -ExpandProperty NetworkAdapters | select VMName, SwitchName, IPAddresses | ft -auto

Additionally, only list those that have an IP starting with 192.168.4*

Get-VM -ComputerName svr-hvhost6-27 | select -ExpandProperty NetworkAdapters | where IPaddresses -like “192.168.4*” | select VMName, SwitchName, IPAddresses | ft -auto

Disclaimer: provided “AS IS” with no warranties and confer no rights