Pages: [1]
Print
Author Topic: Get Datacenter of a Cluster  (Read 656 times)
ewannema
Administrator
Newbie
*****
Posts: 30


View Profile WWW
« on: January 15, 2009, 11:57:41 AM »

Code:
# Find the datacenter object that is hosting this cluster
Function get_cluster_datacenter
{
Param
(
[VMware.VimAutomation.Client20.ClusterImpl]$cluster = $(throw "Must provide a cluster to get_cluster_datacenter.")
)

$clusview = Get-View $cluster.ID
$parent = Get-View $clusview.Parent

# Keep moving up the tree until we get to the datacenter
for ($parent = (Get-View $clusview.Parent); `
$parent.GetType().FullName -ne "VMware.Vim.Datacenter"; `
$parent = (Get-View $parent.Parent))
{}

$parent
}
« Last Edit: January 15, 2009, 12:08:50 PM by esarakaitis » Logged
Pages: [1]
Print
Jump to: