I found a solution some time ago. Thanks for following up. This is what I ended up doing:
# Goes Through Entire vCenter and gets individual SAN data
Function Get-AllSANData($vcenter, $fileName, $MyDirectory) {
$WarningPreference = "SilentlyContinue"
Connect-VIServer $vcenter -ErrorAction SilentlyContinue -ErrorVariable ConnectError | Out-Null
write-host "Extracting SAN data from" $vcenter "..."
write-host "This will take some time, stop staring at me and go do something else..."
# Loop through each Datacenter in the vCenter - MoRef is the ID
ForEach ($datacenter in Get-View -ViewType Datacenter | Select -Property Name,MoRef) {
# Loop through each Cluster in the Datacenter
ForEach ($cluster in Get-View -ViewType ClusterComputeResource -SearchRoot $datacenter.MoRef | Select -Property Name,Datastore) {
# Create Datastore view and Loop through each datastore in the cluster
ForEach ($datastore in $cluster.Datastore) {
$ds = Get-View -Id $datastore | Select -Property Name,Host,Summary,Info # Create Datastore view with current Datastore in Cluster
$hostcount = $ds.Host.Length # Num of Hosts associated with this SAN Volume
if ($hostcount -lt 2) { continue } # Ignore Boot Volumes
$type = $ds | %{$_.Summary.Type} # The type needs to be VMFS, not interesting in NAS or any other type
# Don't filter for VDT Recons - need NFS Storage as well
if ($type -ne "VMFS") { continue }
$lunsize = $ds | %{[decimal]::round($_.Summary.Capacity / 1GB)} # Capacity in Bytes converted to GB
$free = $ds | %{[decimal]::round($_.Summary.FreeSpace / 1GB)} # Free Space in Bytes converted to GB
$uncommitted = $ds | %{[decimal]::round($_.Summary.Uncommitted / 1GB)} # Uncommitted Storage in Bytes converted to GB
$provisioned = ($lunsize - $free + $uncommitted)
$majorversion = $ds | %{$_.Info.Vmfs.MajorVersion} # Major VMFS Version (5.blah = 5) you get the idea
$upperVC = $vcenter.ToString().ToUpper()
$upperCL = $cluster.Name.ToString().ToUpper()
$upperDS = $ds.Name.ToString().ToUpper()
write-host $datacenter.Name . $upperCL . $upperDS . $lunsize . $provisioned . $free . $type . $majorversion . $hostcount
# Output Data to CSV (file is located in same directory that the script runs from)
$record = $datacenter.Name+","+$upperCL+","+$upperDS+","+$lunsize+","+$provisioned+","+$free+","+$type+","+$majorversion+","+$hostcount
$record | Out-File -Append $MyDirectory\SANpulls\$fileName -Encoding ASCII
}
}
}