Skip to content

Instantly share code, notes, and snippets.

@Stephanevg
Last active August 4, 2017 13:53
Show Gist options
  • Save Stephanevg/907155f61b0d8ee6ab0ee81df980139f to your computer and use it in GitHub Desktop.
Save Stephanevg/907155f61b0d8ee6ab0ee81df980139f to your computer and use it in GitHub Desktop.
Returns the Storage Pods that are attached to a specefic cluster
Function Get-ClusterDataStore {
<#
.SYNOPSIS
Retrieves the datastores that are attached to a cluster
.DESCRIPTION
Returns
.EXAMPLE
$Cluster = Get-Cluster "Cluster01"
Get-ClusterDataStore -Cluster $Cluster
#Returns all the Storage pods objects that are attached to the Cluster
.EXAMPLE
$Cluster = Get-Cluster "Cluster01"
Get-ClusterDataStore -Cluster $Cluster | Select Name
#Returns all the datastores Names attached to the Cluster
.NOTES
-Author: Stephane van Gulick
-Email :
-CreationDate: 08.04.2017
-LastModifiedDate: 08.04.2017
-Version: 1.0
-History:
08.04.2017;SVG;Creation
.LINK
http://www.powershellDistrict.com
.OUTPUTS
VMware.Vim.StoragePod
#>
[CmdletBinding()]
Param(
[VMware.VimAutomation.ViCore.Impl.V1.Inventory.ClusterImpl]$Cluster
)
$ClusterView = $Cluster | Get-view
$DataStorePods = get-view -viewType StoragePod
#$DataStorePods = $pods.childEntity.Value
$AllClusterDataStores = @()
Foreach ($Clu in $ClusterView){
foreach ($volume in $Clu.Datastore.value){
$Childentity = $null
$Childentity = $DataStorePods | ? {$_.childentity.value -contains $volume}
if ($childEntity){
if ($AllClusterDataStores.name -contains $Childentity.Name){
continue
}else{
$AllClusterDataStores += $Childentity
}
}
}
}
return $AllClusterDataStores
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment