I am working on a script to report on all vSAN disks/diskgroups etc. and I'm trying to add one field and I can't find a decent way to do it.
I want to add which HBA a vsandisk is attached to, to ensure we don't have disks in a same disk group attached to different controllers.
Any insight would be appreciated 🙂 (I also need to round up the storage values. Don't like the way it's presented right now)...
Try something like this
Foreach ($VSCluster in $VSANClusters) {
Write-Host "[$VSCluster]".ToUpper() -ForegroundColor White
$AllHosts = Get-VMHost -Location $VSCluster.Name| Sort Name
Foreach ($ESXiHost in $AllHosts) {
Write-Host "$([string]::new('-',84))" -ForegroundColor green
Write-Host $EsxiHost.Name -ForegroundColor green
Write-Host "$([string]::new('-',84))" -ForegroundColor green
$AllvSANDG = Get-VsanDiskGroup -vmhost $EsxiHost.Name | Sort Name
Write-Host "Number of Disk Groups : " $AllvSANDG.Count
foreach ($vSANDG in $AllvSANDG) {
Write-Host $vSANDG.Name -ForegroundColor yellow
$DGDisks = Get-VsanDisk -DiskGroup $vSANDG
Write-Host "Number of disks in this group: " $DGDisks.Count -foregroundcolor yellow
$Details = $DGDisks.ExtensionData
$Details | Select CanonicalName, OperationalState, Vendor, Model, Revision, SSD, QueueDepth,
@{N = 'Capacity'; E = {($_.Capacity.BlockSize * $_.Capacity.Block) / 1GB}},
@{N = 'HBA'; E = {
$device = $_.CanonicalName
(Get-VMHostHba -VMHost $ESXiHost -Type FibreChannel |
where {(Get-ScsiLun -Hba $_).CanonicalName -contains $device}).Device -join '|'}
} |
FT -Autosize
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
Foreach ($VSCluster in $VSANClusters) {
Write-Host "[$VSCluster]".ToUpper() -ForegroundColor White
$AllHosts = Get-VMHost -Location $VSCluster.Name| Sort Name
Foreach ($ESXiHost in $AllHosts) {
Write-Host "$([string]::new('-',84))" -ForegroundColor green
Write-Host $EsxiHost.Name -ForegroundColor green
Write-Host "$([string]::new('-',84))" -ForegroundColor green
$AllvSANDG = Get-VsanDiskGroup -vmhost $EsxiHost.Name | Sort Name
Write-Host "Number of Disk Groups : " $AllvSANDG.Count
foreach ($vSANDG in $AllvSANDG) {
Write-Host $vSANDG.Name -ForegroundColor yellow
$DGDisks = Get-VsanDisk -DiskGroup $vSANDG
Write-Host "Number of disks in this group: " $DGDisks.Count -foregroundcolor yellow
$Details = $DGDisks.ExtensionData
$Details | Select CanonicalName, OperationalState, Vendor, Model, Revision, SSD, QueueDepth,
@{N = 'Capacity'; E = {($_.Capacity.BlockSize * $_.Capacity.Block) / 1GB}},
@{N = 'HBA'; E = {
$device = $_.CanonicalName
(Get-VMHostHba -VMHost $ESXiHost -Type FibreChannel |
where {(Get-ScsiLun -Hba $_).CanonicalName -contains $device}).Device -join '|'}
} |
FT -Autosize
}
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you. I was going that route but didn't quite know how to format it. Much appreciated.
Is there an attribute that shows if it's a cache disk or capacity disk?
Not sure, I'll have to dig into the VSAN API :smileygrin:
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference