I would like to modify the code snippet below (http://kb.vmware.com/kb/1012514) to include the parent object.
get-view -ViewType HostSystem -Property Name, Config.Product | select Name,{$_.Config.Product.FullName},{$_.Config.Product.Build} | ft -auto
When I run the modified version I get "ComputeResource-domain-sNNNN" or "ClusterComputeResource-domain-cNNN" in the Parent column. If I do a
Get-Cluster ClusterComputeResource-domain-cNNN
I get the name of one of our clusters. So I tried variations of the following and I still can't get a proper Parent name.
PowerCLI C:\> get-view -ViewType HostSystem -Property Name, Config.Product, Parent | select Name,{$_.Config.Product.FullName},{$_.Config.Product.Build}, ( $_.Parent | get-cluster ) | sort -property name | ft -auto
select : Cannot convert System.Object[] to one of the following types {System.String, System.Management.Automation.ScriptBlock}.
At line:1 char:72
+ get-view -ViewType HostSystem -Property Name, Config.Product, Parent | select Na ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Select-Object], NotSupportedException
+ FullyQualifiedErrorId : DictionaryKeyUnknownType,Microsoft.PowerShell.Commands.SelectObjectCommand
PowerCLI C:\>
I realize that it doesn't help that in some cases Parent will be a cluster object and other cases it will be a Folder or Data Center object. I have also tried
.... $( if ( $_.Parent) {get-cluster -id $_.Parent} )
.... ( if ( $_.Parent) {get-cluster -id $_.Parent} )
.... ( get-cluster -name ($_.Parent).Name )
.... ( get-cluster -name [string]($_.Parent).Name )
1) If I only care about hosts with cluster parents, is there a way to ignore all others?
2) How do I get the name of the parent cluster?