VMware Cloud Community
RobMerritt
Contributor
Contributor
Jump to solution

MAC address and IP using powerCLI

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.*" }

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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.*" }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership
Jump to solution

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.*" }


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
RobMerritt
Contributor
Contributor
Jump to solution

hey that did the trick!

0 Kudos