Automation

 View Only
  • 1.  find vm by MAC address in a specific cluster...

    Posted Oct 23, 2019 07:52 AM

    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



  • 2.  RE: find vm by MAC address in a specific cluster...

    Posted Oct 23, 2019 08:15 AM


  • 3.  RE: find vm by MAC address in a specific cluster...
    Best Answer

    Posted Oct 23, 2019 01:11 PM

    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