Thanks for a VERY useful script! - a bit of editing and here is a script version that lists ALL VM's (not just the ones that are included in clusters) - also inluded secondary IP's and MASK's so that IPv4 and IPv6 are shown:
foreach($vm in (Get-VM)){
$vm.ExtensionData.Guest.Net | Select @{N="VM";E={$vm.Name}},MacAddress,Network,
@{N="DHCP";E={$_.IpConfig.Dhcp.Ipv4.Enable}},
@{N="IP-1";E={$_.IpAddress[0]}},
@{N="Subnet Mask-1";E={
$dec = [Convert]::ToUInt32($(("1" * $_.IpConfig.IpAddress[0].PrefixLength).PadRight(32, "0")), 2)
$DottedIP = $( For ($i = 3; $i -gt -1; $i--) {
$Remainder = $dec % [Math]::Pow(256, $i)
( $dec - $Remainder) / [Math]::Pow(256, $i)
$dec = $Remainder
} )
[String]::Join('.', $DottedIP)
}},
@{N="IP-2";E={$_.IpAddress[1]}},
@{N="Subnet Mask-2";E={
$dec = [Convert]::ToUInt32($(("1" * $_.IpConfig.IpAddress[1].PrefixLength).PadRight(32, "0")), 2)
$DottedIP = $( For ($i = 3; $i -gt -1; $i--) {
$Remainder = $dec % [Math]::Pow(256, $i)
( $dec - $Remainder) / [Math]::Pow(256, $i)
$dec = $Remainder
} )
[String]::Join('.', $DottedIP)
}}
}
- Erkka Hakkarainen