$DataStoreViews = Get-View -ViewType Datastore -Server $vCenter -Property Name, Info | Sort Name
$DataStoreClusterViews = Get-View -ViewType StoragePod -Server $vCenter -Property Name, ChildEntity
ForEach($DataStoreView in $DataStoreViews){
$DataStoreClusterView = $Null
$DataStoreClusterView = $DataStoreClusterViews | Where{($_.ChildEntity -Contains $DataStoreView.MoRef) -AND ($_.Client.ServiceUrl.Split('/')[2] -eq $DataStoreView.Client.ServiceUrl.Split('/')[2])}
$DataStoreView | Select Name, OverallStatus, @{N="CanonicalName";E={$_.Info.Vmfs.Extent.DiskName}}, @{N="DSCluster"; E={$DataStoreClusterView.Name}}
}
Original Message:
Sent: Apr 03, 2025 02:35 PM
From: dbutch1976
Subject: Get datastore with cluster name
Hello,
I'm trying to get a list of all datastores in my environment with their naa numbers which is pretty easy with this command:
Get-Datastore | select Name,State,@{N="naa";E={$_.ExtensionData.Info.Vmfs.Extent.DiskName}}
I would also like to add the datastorecluster name when the datastore resides in a datastorecluster. The challenge is that some of these reside in clusters, others do no, but I want to make sure I list all the datastores in my environment.
Any suggestions?