This is what I tried:
foreach ($Cluster in (Get-Cluster -Location $Datacenter | Sort-Object $Cluster)) {
What I am trying to accomplish is to have the report sorted in the order as ii looks when you open the vSphere client.
I've tried to sort by vCenter but I'm not getting the desired results:
# Function to perform the work for the data you need
Function GetCluster {
& { foreach ($Datacenter in (Get-Datacenter)) {
foreach ($Cluster in (Get-Cluster -Location $Datacenter)) {
$clusObj = New-Object -TypeName PSObject -Property @{
vCenter = $Datacenter.Uid.Split("@")[1].Split(":")[0] | Sort-Object -Property Name
Datacenter = $Datacenter.Name
Cluster = $Cluster.Name
HAEnabled = $Cluster.HAEnabled
DrsEnabled = $Cluster.DrsEnabled
DrsMode = $Cluster.DrsMode
}
writedata $clusObj
}
}
}
}