T180985
Expert
Expert

find vm by MAC address in a specific cluster...

Jump to solution

Hi! Im trying to find a way of searching for a specific VM by its MAC address... currently i have the following

$global:selection = Read-Host "Please enter MAC address"

Get-Datacenter $global:DCChoice | Get-Cluster $global:CLUChoice | Get-vm | Select Name, @{N=“NIC“;E={$_ | Get-networkAdapter | select Name}}, @{N=“MAC“;E={$_ | Get-networkAdapter | select -ExpandProperty MacAddress}} | Where {$_.MacAddress -eq $global:selection}

everything works up until i pipe through "Where"... any tips?

also, the NIC naming doesnt look right to me? can this be changed to remove the @{Name= }

Name                                  NIC                       MAC

----                                         ---                       ---

VMNAME1 @{Name=Network adapter 1}  00:50:56:B7:C2:5D

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums
0 Kudos
1 Solution

Accepted Solutions
T180985
Expert
Expert

Managed to get it working with:

> $global:selection = Read-Host "Please enter MAC address"

> Get-Datacenter $global:DCChoice | Get-Cluster $global:CLUChoice | Get-vm | Get-networkAdapter | Where {$_.MacAddress -like "$global:selection"} | Select Parent, Name, NetworkName,       MacAddress

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
0 Kudos
T180985
Expert
Expert

Managed to get it working with:

> $global:selection = Read-Host "Please enter MAC address"

> Get-Datacenter $global:DCChoice | Get-Cluster $global:CLUChoice | Get-vm | Get-networkAdapter | Where {$_.MacAddress -like "$global:selection"} | Select Parent, Name, NetworkName,       MacAddress

Please mark helpful or correct if my answer resolved your issue. How to post effectively on VMTN https://communities.vmware.com/people/daphnissov/blog/2018/12/05/how-to-ask-for-help-on-tech-forums

View solution in original post

0 Kudos