PowerCLI

 View Only
  • 1.  MAC address and IP using powerCLI

    Posted Mar 25, 2024 11:35 PM

    I can get MAC of a VM and I can get IP of a vm but how do I combined them ?

     

    $mac = Get-VM $item | Get-NetworkAdapter | select MacAddress

    $collectionsON = Get-VM | Select @{Label = "VMName" ; Expression = {$_.Name} },@{Label = "GuestOS" ; Expression = {$_.ExtensionData.Config.GuestFullName} },@{N="IP";E={@($_.guest.IPaddress)|?{$_ -notmatch ':'}}},@{N="POWER";E={@($_.PowerState)}} | Where-Object {$_.GuestOS -match ".*inux.*" } | Where-Object {$_.POWER -match ".*PoweredOn.*" }



  • 2.  RE: MAC address and IP using powerCLI
    Best Answer

    Posted Mar 26, 2024 07:04 AM

    You could do something like this

    $collectionsON = Get-VM | 
    Select @{Label = "VMName" ; Expression = {$_.Name} },
        @{Label = "GuestOS" ; Expression = {$_.ExtensionData.Config.GuestFullName} },
        @{N="IP";E={@($_.guest.IPaddress)|?{$_ -notmatch ':'}}},
        @{N='MAC';E={(Get-NetworkAdapter -VM $_).MacAddress -join '|'}},
        @{N="POWER";E={@($_.PowerState)}} | 
    Where-Object {$_.GuestOS -match ".*inux.*" -and $_.POWER -match ".*PoweredOn.*" }


  • 3.  RE: MAC address and IP using powerCLI

    Posted Mar 26, 2024 05:19 PM

    hey that did the trick!



  • 4.  RE: MAC address and IP using powerCLI

    Posted Oct 30, 2025 01:13 PM

    Hi LucD,

    For VMs without VMware Tools, the IP address is not displayed in vCenter. Is there a way to get the MAC address from an IP address using PowerCLI?

    -------------------------------------------



  • 5.  RE: MAC address and IP using powerCLI

    Posted Dec 26, 2025 09:41 PM

    LucD retired.

    Your options are use network tools on the same subnet, or retrieve the mac address assigned via the Virtual HW, but there will be no direct map to the IP. If the VM has only one nic and IP, and you know the machine name, the DNS point to the IP, and the vHW MAC should be assigned to the one IP.

    -------------------------------------------