I've searched the forums but haven't found the answer for this, but please let me know if I missed it. Given a VM name, I would like to output a list of hosts that the VM can run on. The only way that I have been able to do this is a two step process and I'm trying to get it into a one liner:
Suppose the VM name is SQLVS01
$a = foreach ($vmname in get-vmhost -vm SQLVS01){get-cluster -vmhost $vmname}
Check the value of $a for example purposes:
$a
Name HAEnabled HAFailover DrsEnabled DrsAutomationLe
Level vel
-
-
-
-
-
SQLCluster1 True 1 True FullyAutomated
Use the retrieved cluster name as a parameter:
C:\> get-vmhost -location $a.name
Output shows the VMHosts in that cluster
Name
-
VMHost1
VMHost2
..etc..
Any ideas? This must be simpler than I am making it.
Thanks,
Ed