Skip to content

Instantly share code, notes, and snippets.

@gowatana
Last active December 6, 2020 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gowatana/c24ba1d4e80af83c9bf6006749d2e5dd to your computer and use it in GitHub Desktop.
Save gowatana/c24ba1d4e80af83c9bf6006749d2e5dd to your computer and use it in GitHub Desktop.
# 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 vCenter
$vc = $global:DefaultVIServer
$vc_info = $vc | select Name,Version,Build | Sort-Object Name
report_table "vCenter Info" $vc_info
# get vSAN Clusters.
$vsan_clusters = Get-Cluster | where {$_.VsanEnabled -eq $True} | Sort-Object 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)
# ESXi
$hvs = Get-Cluster -Name $vsan_cluster.Name | Get-VMHost
$hv_info = $hvs | Sort-Object Name | select `
Name,
Version,
Build,
ConnectionState,
PowerState,
NumCpu,
@{N="MemoryGB";E={[int]$_.MemoryTotalGB}},
Model
report_table "ESXi Info" $hv_info
# DG
$vsan_dgs = $vsan_cluster | Get-VsanDiskGroup
$vsan_dg_info = $vsan_dgs | Sort-Object 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-Object 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
}
@gowatana
Copy link
Author

gowatana commented Dec 6, 2020

↑リンク修正ずみ。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment