Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$HyperVHosts = @('NodeHV1','NodeHV2')
$IPAddress = '10.2.3'
$SelectObjectFilter = @(
@{name = 'VMName'; e={$PSItem.VMName}},
@{name = 'ComputerName';e={$PSItem.ComputerName}},
@{name = 'IPAddress';e={$PSItem.IPAddresses}},
@{name = 'SwitchName';e={$PSItem.SwitchName}},
@{name = 'MacAddress';e={$Psitem.MacAddress}}
)
Get-VM -ComputerName $HyperVHosts |
Get-VMNetworkAdapter |
Where-Object {$PSItem.Ipaddresses -match $IPAddress} |
Select-Object $SelectObjectFilter |
Format-Table -AutoSize
VMName ComputerName IPAddress SwitchName MacAddress
------ ------------ --------- ---------- ----------
WSUSR0W10-1703 NodeHV1 {10.2.3.83, fe80::316e:5cb4:c90d:6baa} External-Team1VMs 00155D039D0D
WSUSR0W10-1709c NodeHV1 {10.2.3.70, fe80::c1c9:9094:d0bc:e72a} External-Team1VMs 00155D039D08
TestMachine1 NodeHV2 {10.2.3.161, fe80::51b:e8c9:e1b9:f9c7} External-Team1VMs 00155DFC4D2E
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.