any idea why the below script is not giving me all my output of my VMs? I am missing VMs
$clusters = get-cluster
foreach ($cluster in $clusters) {
$vmhosts = $cluster | get-vmhost
foreach ($vmhost in $vmhosts){
$vms = $vmhost | get-vm
foreach ($vm in $vms) {
$vminfo = New-Object -TypeName PSObject
$vminfo | Add-Member -MemberType NoteProperty -Name VM -Value $vm.Name
$vminfo | Add-Member -MemberType NoteProperty -Name Powerstate -Value $vm.PowerState
$vminfo | add-member -membertype NoteProperty -name VMHost -value $vmhost.Name
$vminfo | add-member -MemberType NoteProperty -Name Clustername -Value $cluster.Name
}
$report += $vminfo
}
}
write-host $report