vSAN Configuration Report

August 15, 2018 – 11:15 am

Here’s a script I put together from various sources to report on the disk group configurations for a VSAN cluster. Hope you find it useful!

########################################################################
# Script : vSAN Configuration Report
# Author : Marc Bouchard
# Version : 1.0
#
# Generate a report of the vSAN Configuration.
# – Clusters with vSAN
# – Disk groups on each host
# – Disk details for each disk group, including HBA each disk is attached to
#
########################################################################
Clear
$VSANArray = @()
$vSANClusters = Get-VsanClusterConfiguration | where {$_.vsanenabled -eq “true”}
# Collect data from all clusters, nodes, disk groups and disks
Foreach ($VSCluster in $VSANClusters) {
    write-host “[$VSCluster]”.ToUpper() -foregroundcolor White
    $AllHosts=Get-VMHost -Location $VSCluster.Name| Sort Name
    Foreach ($ESXiHost in $AllHosts) {
        write-host “————————————————————————————” -foregroundcolor green
        write-host $EsxiHost.Name -foregroundcolor green
        write-host “————————————————————————————” -foregroundcolor green
        $AllvSANDG = Get-vSANDiskGroup -VMHost $EsxiHost.Name | Sort Name
        Write-Host “Number of Disk Groups : ” $AllvSANDG.Count
        $DGCount = 0
        foreach ($DiskGroup in $AllvSANDG) {
            $DGCount += 1
            write-host $DiskGroup.Name -foregroundcolor yellow
            $DGDisks=get-vsandisk -diskgroup $DiskGroup
            Write-Host “Number of disks in this group: ” $DGDisks.Count -foregroundcolor yellow
            $DiskCount = 0
            foreach ($vSANDisk in $DGDisks) {
                $DiskCount += 1
                $Details=$vSANDisk.extensiondata
                $DiskName=$Details.CanonicalName
                Write-Host “Processing disk #$DiskCount : $DiskName” -foregroundcolor cyan
                $SCSILUN = ($ESXiHost | get-scsilun -CanonicalName $Details.CanonicalName)
                $vmHBA = $SCSILUN.RuntimeName.Substring(0, ($SCSILUN.RuntimeName.IndexOf(“:”)))
                $VSANObject = New-Object System.Object
                $VSANObject | Add-Member -type NoteProperty -name Cluster       -Value $VSCluster.Name
                $VSANObject | Add-Member -type NoteProperty -name Host          -Value $ESXiHost.Name
                $VSANObject | Add-Member -type NoteProperty -name vmHBA         -Value $vmHBA
                $VSANObject | Add-Member -type NoteProperty -name GroupID       -Value $DGCount
                $VSANObject | Add-Member -type NoteProperty -name GroupName     -Value $DiskGroup.Name
                $VSANObject | Add-Member -type NoteProperty -name DiskID        -Value $DiskCount
                $VSANObject | Add-Member -type NoteProperty -name DiskName      -Value $Details.CanonicalName
                $VSANObject | Add-Member -type NoteProperty -name State         -Value $Details.OperationalState
                $VSANObject | Add-Member -type NoteProperty -name Vendor        -Value $Details.Vendor
                $VSANObject | Add-Member -type NoteProperty -name Model         -Value $Details.Model
                $VSANObject | Add-Member -type NoteProperty -name Revision      -Value $Details.Revision
                $VSANObject | Add-Member -type NoteProperty -name IsSSD         -Value $Details.SSD
                $VSANObject | Add-Member -type NoteProperty -name QueueDepth    -Value $Details.QueueDepth
                $VSANObject | Add-Member -type NoteProperty -name Capacity      -Value (($Details.Capacity.BlockSize * $Details.Capacity.Block) / 1GB)
                $VSANArray += $VSANObject
            }
        }
    }
}
$VSANArray | Export-CSV vsanConfig.csv

Post a Comment