Is it possible to create a property that accesses the cluster name that a VM is on, such as this:
get-vm | select name,
@{n="cluster";e={ GetTheClusterNameSomehow}}
?
Thanks!
Something like this should do the trick.
$vm = Get-VM -Name MyVM
$vm | Select Name,@{n="Cluster";E={
$rp = Get-View $_.ExtensionData.ResourcePool
$parent = Get-View $rp.Parent
While ($parent -isnot [VMware.Vim.ClusterComputeResource]){
$parent = Get-View $parent.Parent
}
$parent.Name
}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Something like this should do the trick.
$vm = Get-VM -Name MyVM
$vm | Select Name,@{n="Cluster";E={
$rp = Get-View $_.ExtensionData.ResourcePool
$parent = Get-View $rp.Parent
While ($parent -isnot [VMware.Vim.ClusterComputeResource]){
$parent = Get-View $parent.Parent
}
$parent.Name
}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK thanks