I did not write this, I found it online but lost the link, but it works great!
ForEach ($VirtualMachine in $VM) {
# Get the virtual machine
$VMsView = Get-View -ViewType VirtualMachine -Property Name,Guest.Net -Filter @{"Name"="$VirtualMachine$"}
if ($VMsView) {
$VMsView | `
ForEach-Object {
$VMview = $_
$VMView.Guest.Net | `
Select-Object -property @{N="VM";E={$VMView.Name}},
MacAddress,
IpAddress,
Connected
}
}
}
No comments:
Post a Comment