Monday, February 27, 2012

Get all VMs and the MAC address, Duplicate IPs

1. ESXi with
Get-VMHostNetworkAdapter | select VMhost, Name, Mac,Ip
Get-VMHost|Get-VMHostNetworkAdapter
Get-VMHost|Get-VirtualSwitch


2. Get-VM | `Select-Object -Property Name,@{N="MacAdresses";E={$_.NetworkAdapters | ForEach-Object {$_.MacAddress}}},VMHost`


3. Connect-VIServer -Server vSphereServer

$match_address = "172......3"

Get-VM | %{
$vmIPs = $_.Guest.IPAddress
foreach($ip in $vmIPs) {
if ($ip -eq $match_address) {
"Found VM with matching address: {0}" -f $_.Name
}
}
}


4. Get-VMHost |Get-VMHostNetworkAdapter | Where-Object {$_.Mac -eq "00:25:90:2a:6a:a2"}


5.Get-VM -Location Proteus-Cluster | where {$_.'PowerState' -eq "PoweredOn"} | `Select-Object VMHost,Name`

( Verified the number of powered on VMs are the same - 41)
172.16.13.1 Jenkins-Dogfood-Proteus
172.16.13.1 build-amazon-vm-0
172.16.13.1 steve-windows