VMware Cloud Community
jzim
Contributor
Contributor

get-view: how to use the filter option for host parent

I need to do a get-view on all the hosts in a cluster, I know I can use the get-vmhost -location to get all the hosts then do a get-view on each one. I found that if I do a get-view (get-cluster testCluster) this returns a MoRef equal to ClusterComputeResource-domain-c31 , when I do a get-view -viewtype hostsystem on a host in the same cluster, the parent returned is the moref from the get-view on the cluster. So I tied to do a:

get-view -viewtype hostsystem -filter @{"Parent"="ClusterComputeResource-domain-c31"}

But this doesn't return anything. How can I use the filter option to return a view of all the hosts in a cluster?

Thanks

Reply
0 Kudos
1 Reply
LucD
Leadership
Leadership

Try it like this

Get-View -ViewType HostSystem -Filter @{"Parent"="^domain-c31$"}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos