Guest User

Untitled

a guest
Feb 20th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.29 KB | None | 0 0
  1. # vSAN Summary Report Script.
  2. #
  3. # Created by: Go Watanabe / @gowatana
  4. # Usage:
  5. # PowerCLI> .\get_vsan_summary.ps1 | Out-File -Encoding utf8 -PSPath vsan-report.txt
  6.  
  7. $report_width = 140
  8.  
  9. function report_header ($report_title) {
  10. "/" * $report_width
  11. "# $report_title"
  12. ""
  13. }
  14.  
  15. function report_table ($report_title, $report) {
  16. "-" * $report_width
  17. "# $report_title"
  18. ""
  19. $report = $report | ft -AutoSize | Out-String
  20. $report.Trim()
  21. ""
  22. }
  23.  
  24. report_header ("vSAN Cluster Summary: " + (Get-Date).DateTime)
  25.  
  26. # get vSAN Clusters.
  27. $vsan_clusters = Get-Cluster | where {$_.VsanEnabled -eq $True} | sort Name
  28.  
  29. # Cluster
  30. $vsan_cluster_config = $vsan_clusters | Get-VsanClusterConfiguration | select `
  31. Cluster,
  32. VsanEnabled,
  33. VsanDiskClaimMode,
  34. SpaceEfficiencyEnabled,
  35. StretchedClusterEnabled,
  36. WitnessHost
  37. report_table "vSAN Cluster Configuration" $vsan_cluster_config
  38.  
  39. $vsan_clusters | % {
  40. $vsan_cluster = $_
  41. report_header ("vSAN Cluster: " + $vsan_cluster.Name)
  42.  
  43. # DG
  44. $vsan_dgs = $vsan_cluster | Get-VsanDiskGroup
  45. $vsan_dg_info = $vsan_dgs | sort VMHost | select `
  46. VMHost,
  47. DiskGroupType,
  48. DiskFormatVersion,
  49. @{N="CacheDisk"; E={($_ | Get-VsanDisk | where {$_.IsCacheDisk -eq $true}).Count}},
  50. @{N="CapacityDisk"; E={($_ | Get-VsanDisk | where {$_.IsCacheDisk -ne $true}).Count}},
  51. Uuid
  52. report_table "vSAN DiskGroup" $vsan_dg_info
  53.  
  54. # Disk
  55. $vsan_disks = $vsan_dgs | % {
  56. $dg = $_
  57. $hv = $dg.VMHost
  58. $dg | Get-VsanDisk | select `
  59. *,
  60. @{N="ESXi";E={$hv.Name}},
  61. @{N="DG_UUID";E={$dg.Uuid}}
  62.  
  63. }
  64. $vsan_disk_info = $vsan_disks | select `
  65. ESXi,
  66. DG_UUID,
  67. IsCacheDisk,
  68. IsSSD,
  69. @{N="CapacityGB"; E={[int]($_.ExtensionData.Capacity | % {$_.BlockSize * $_.Block / 1GB})}},
  70. @{N="CanonicalName"; E={$_.ExtensionData.CanonicalName}} |
  71. sort ESXi,DG_UUID,IsCacheDisk
  72. report_table "vSAN Disk Info" $vsan_disk_info
  73.  
  74. # Capacity
  75. $vsan_datastore = $vsan_cluster | Get-Datastore | where {$_.Type -eq "vsan"}
  76. $vsan_datastore_info = $vsan_datastore | select `
  77. Name,
  78. Type,
  79. @{N="CapacityGB";E={[int]$_.CapacityGB}},
  80. @{N="FreeGB";E={[int]$_.FreeSpaceGB}},
  81. @{N="ProvisionedGB";E={
  82. [int](($_.CapacityGB - $_.FreeSpaceGB) + ($_.ExtensionData.Summary.Uncommitted / 1GB))
  83. }
  84. }
  85. report_table "vSAN Datastore Capacity" $vsan_datastore_info
  86.  
  87. # Storage Provider
  88. $vasa_providers = $vsan_cluster | Get-VMHost | % {
  89. $hv = $_
  90. Get-VasaProvider | where {($_.Namespace -eq "VSAN") -and ($_.Name -match $hv.Name)}
  91. }
  92. $vasa_providers_info = $vasa_providers | sort Name | select `
  93. Status,
  94. Name,
  95. ProviderId
  96. report_table "VASA Provider Info" $vasa_providers_info
  97.  
  98. # Active Storage Provider
  99. $active_vasa_provider = Get-VasaStorageArray |
  100. where {$_.ModelId -eq "VSAN"} |
  101. where {$_.Id -eq ($vsan_datastore.ExtensionData.Info.Url -replace "ds:///vmfs/volumes/|/$","")}
  102. $active_vasa_provider_info = $active_vasa_provider | select `
  103. @{N="vsanDatastore"; E={$vsan_datastore.Name}},
  104. Provider,
  105. Id
  106. report_table "Active VASA Provider Info" $active_vasa_provider_info
  107. }
Add Comment
Please, Sign In to add comment