vSAN Storage Policy Summary using PowerCLI

I recently came across a need to review the Storage Policies in use within a vCenter environment and how many objects or virtual machines where using each policy. I saw this as an excuse to refresh my PowerShell skills and wrote a quick function. Source code can be found on my GitHub, here. Check there for any updates but below is the code at the time of writing. function Get-vSANSPSummary { <# .SYNOPSIS Export vSAN Storage Policy Information. .DESCRIPTION Export vSAN Storage Policies from vCenter showing FTT & Stripe information and amount of amount of VM's using each. .PARAMETER ExportPath Path the export the output HTML file. .NOTES Tags: VMware, vCenter, SPBM, PowerCLI, API Author: Stephan McTighe Website: stephanmctighe.com .EXAMPLE PS C:\> Get-vSANSPSummary -ExportPath "C:\report\vSAN-Storage-Policy-Summary.html" Outputs a HTML file containing the Storage Policy Information for vSAN Storage Policies to a specified location. #> #Requires -Modules VMware.VimAutomation.Storage [CmdletBinding()] param ( [Parameter(Mandatory)] [string] $ExportFilePath) Begin {} Process { try { $Output = @() $vSANstoragepolicies = Get-SpbmStoragePolicy -Namespace "VSAN" $SPBM = $vSANstoragepolicies | Select-Object Name, AnyOfRuleSets ForEach ($SP in $SPBM) { $Attributes = @( $SP | ForEach-Object { $_.AnyOfRuleSets } | Select-Object -ExpandProperty AllofRules) $object = [PSCustomObject]@{ SPName = $SP.Name ObjectCount = $ObjectCount = (Get-SpbmEntityConfiguration -StoragePolicy "$($SP.name)").count VMCount = $VMCount = (Get-SpbmEntityConfiguration -StoragePolicy "$($SP.Name)" | Where-Object {$_.Entity -notlike "hard*"}).count RAID = $attributes | Where-Object { $_.Capability -like "*VSAN.replicaPreference*" } | Select-Object -ExpandProperty Value FTT = $attributes | Where-Object { $_.Capability -like "*VSAN.hostFailuresToTolerate*" } | Select-Object -ExpandProperty Value SubFTT = $attributes | Where-Object { $_.Capability -like "*VSAN.subFailuresToTolerate*" } | Select-Object -ExpandProperty Value Stripes = $attributes | Where-Object { $_.Capability -like "*VSAN.stripeWidth*" } | Select-Object -ExpandProperty Value ForceProvision = $attributes | Where-Object { $_.Capability -like "*VSAN.forceProvisioning*" } | Select-Object -ExpandProperty Value StorageType = $attributes | Where-Object { $_.Capability -like "*VSAN.storageType*" } | Select-Object -ExpandProperty Value IOPSLimit = $attributes | Where-Object { $_.Capability -like "*VSAN.iopsLimit*" } | Select-Object -ExpandProperty Value } $Output += $object } $Output | ConvertTo-Html -Property SPName, VMCount, ObjectCount, RAID, FTT, SubFTT, Stripes, ForceProvision, StorageType, IOPSLimit | Out-File $ExportFilePath } catch { Write-Host "An error occurred!" -ForegroundColor Red Write-Host $_ -ForegroundColor Red } } } Output currently as a basic HTML table but you could change this to add some ‘HTMLness’ or output to CSV.