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.*" }
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
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
hey that did the trick!