5 Replies Latest reply on May 17, 2018 6:54 AM by LucD

    vSAN Configuration report

    MarcBouchard Enthusiast
    vExpert

      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)...

      $vSANClusters = Get-VsanClusterConfiguration | where {$_.vsanenabled -eq "true"}
       
      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
       
      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) / (1024*1024*1024)}}| FT -Autosize
      }
      }
      }
      clear
      $vSANClusters = Get-VsanClusterConfiguration | where {$_.vsanenabled -eq "true"}
       
      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
       
      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) / (1024*1024*1024)}}| FT -Autosize
      }
      }
      }
        • 1. Re:vSAN Configuration report
          MarcBouchard Enthusiast
          vExpert
          This is just the foundation of the script, my goal is to create an HTML file or word document that represents the disk groups, with their associated details, for each host. I will share the end result once completed.
          • 2. Re:vSAN Configuration report
            LucD Guru
            User ModeratorsCommunity WarriorsvExpert

            Try something like this

             

            $vSANClusters = Get-VsanClusterConfiguration | where {$_.vsanenabled -eq "true"}

             

            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

              }

              }

            }

            • 3. Re:vSAN Configuration report
              MarcBouchard Enthusiast
              vExpert

              Thank you. I was going that route but didn't quite know how to format it. Much appreciated.

              • 4. Re:vSAN Configuration report
                MarcBouchard Enthusiast
                vExpert

                Is there an attribute that shows if it's a cache disk or capacity disk?

                • 5. Re:vSAN Configuration report
                  LucD Guru
                  User ModeratorsCommunity WarriorsvExpert

                  Not sure, I'll have to dig into the VSAN API