Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # vSAN Summary Report Script.
- #
- # Created by: Go Watanabe / @gowatana
- # Usage:
- # PowerCLI> .\get_vsan_summary.ps1 | Out-File -Encoding utf8 -PSPath vsan-report.txt
- $report_width = 140
- function report_header ($report_title) {
- "/" * $report_width
- "# $report_title"
- ""
- }
- function report_table ($report_title, $report) {
- "-" * $report_width
- "# $report_title"
- ""
- $report = $report | ft -AutoSize | Out-String
- $report.Trim()
- ""
- }
- report_header ("vSAN Cluster Summary: " + (Get-Date).DateTime)
- # get vSAN Clusters.
- $vsan_clusters = Get-Cluster | where {$_.VsanEnabled -eq $True} | sort Name
- # Cluster
- $vsan_cluster_config = $vsan_clusters | Get-VsanClusterConfiguration | select `
- Cluster,
- VsanEnabled,
- VsanDiskClaimMode,
- SpaceEfficiencyEnabled,
- StretchedClusterEnabled,
- WitnessHost
- report_table "vSAN Cluster Configuration" $vsan_cluster_config
- $vsan_clusters | % {
- $vsan_cluster = $_
- report_header ("vSAN Cluster: " + $vsan_cluster.Name)
- # DG
- $vsan_dgs = $vsan_cluster | Get-VsanDiskGroup
- $vsan_dg_info = $vsan_dgs | sort VMHost | select `
- VMHost,
- DiskGroupType,
- DiskFormatVersion,
- @{N="CacheDisk"; E={($_ | Get-VsanDisk | where {$_.IsCacheDisk -eq $true}).Count}},
- @{N="CapacityDisk"; E={($_ | Get-VsanDisk | where {$_.IsCacheDisk -ne $true}).Count}},
- Uuid
- report_table "vSAN DiskGroup" $vsan_dg_info
- # Disk
- $vsan_disks = $vsan_dgs | % {
- $dg = $_
- $hv = $dg.VMHost
- $dg | Get-VsanDisk | select `
- *,
- @{N="ESXi";E={$hv.Name}},
- @{N="DG_UUID";E={$dg.Uuid}}
- }
- $vsan_disk_info = $vsan_disks | select `
- ESXi,
- DG_UUID,
- IsCacheDisk,
- IsSSD,
- @{N="CapacityGB"; E={[int]($_.ExtensionData.Capacity | % {$_.BlockSize * $_.Block / 1GB})}},
- @{N="CanonicalName"; E={$_.ExtensionData.CanonicalName}} |
- sort ESXi,DG_UUID,IsCacheDisk
- report_table "vSAN Disk Info" $vsan_disk_info
- # Capacity
- $vsan_datastore = $vsan_cluster | Get-Datastore | where {$_.Type -eq "vsan"}
- $vsan_datastore_info = $vsan_datastore | select `
- Name,
- Type,
- @{N="CapacityGB";E={[int]$_.CapacityGB}},
- @{N="FreeGB";E={[int]$_.FreeSpaceGB}},
- @{N="ProvisionedGB";E={
- [int](($_.CapacityGB - $_.FreeSpaceGB) + ($_.ExtensionData.Summary.Uncommitted / 1GB))
- }
- }
- report_table "vSAN Datastore Capacity" $vsan_datastore_info
- # Storage Provider
- $vasa_providers = $vsan_cluster | Get-VMHost | % {
- $hv = $_
- Get-VasaProvider | where {($_.Namespace -eq "VSAN") -and ($_.Name -match $hv.Name)}
- }
- $vasa_providers_info = $vasa_providers | sort Name | select `
- Status,
- Name,
- ProviderId
- report_table "VASA Provider Info" $vasa_providers_info
- # Active Storage Provider
- $active_vasa_provider = Get-VasaStorageArray |
- where {$_.ModelId -eq "VSAN"} |
- where {$_.Id -eq ($vsan_datastore.ExtensionData.Info.Url -replace "ds:///vmfs/volumes/|/$","")}
- $active_vasa_provider_info = $active_vasa_provider | select `
- @{N="vsanDatastore"; E={$vsan_datastore.Name}},
- Provider,
- Id
- report_table "Active VASA Provider Info" $active_vasa_provider_info
- }
Add Comment
Please, Sign In to add comment