Last active
September 16, 2020 10:50
-
-
Save gowatana/4d5aabee9d5070cafec06cbcf2b49e6b to your computer and use it in GitHub Desktop.
print vSAN disk device config summary.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print vSAN disk device config summary | |
# Created by: gowatana | |
# Usage: | |
# PS> Connect-VIServer | |
# PS> ./list_vsan_disk_device_config.ps1 | |
$log_dir = "./logs" | |
$time_stamp = Get-Date | |
$ts = Get-Date -f "yyyyMMdd_hhmmss" | |
if(-Not (Test-Path $log_dir -ErrorAction:SilentlyContinue)){mkdir $log_dir} | |
$report_csv_file_name_1 = Join-Path $log_dir ("report_vsan_diskgroup_" + $ts +".csv") | |
$report_csv_file_name_2 = Join-Path $log_dir ("report_vsan_disk_" + $ts +".csv") | |
$i=0 | |
$vsan_diskgroups = Get-VsanDiskGroup | Sort-Object VMHost | |
$vsan_diskgroups = foreach ($vsan_diskgroup in $vsan_diskgroups) { | |
$i++ | |
$vsan_diskgroup | Select-Object ` | |
@{N="vSAN_DG_No";E={$i}}, | |
VMHost, | |
@{N="vSAN_DG_UUID";E={$_.Uuid}} | |
} | |
$vsan_disks = Get-VsanDisk | |
$vsan_disks = foreach ($vsan_disk in $vsan_disks) { | |
$vsan_dg_uuid = $vsan_disk.VsanDiskGroup.Uuid | |
$vsan_disk | Select-Object ` | |
@{N="DG_No"; E={($vsan_diskgroups | Where-Object {$_.vSAN_DG_UUID -eq $vsan_dg_uuid}).vSAN_DG_No}}, | |
@{N="Tier"; E={if($vsan_disk.IsCacheDisk -eq $true){"Cache"}else{"Capacity"}}}, | |
@{N="Model";E={$vsan_disk.ExtensionData.Model}}, | |
@{N="CapacityGB";E={[int]$vsan_disk.ScsiLun.CapacityGB}}, | |
@{N="Vendor";E={$vsan_disk.ExtensionData.Vendor}}, | |
@{N="CanonicalName"; E={$vsan_disk.CanonicalName}} | |
} | |
# Add vSAN_Disk_No | |
$i = 0 | |
$vsan_disks = $vsan_disks | Sort-Object DG_No,Tier,CanonicalName | |
$vsan_disks = foreach ($vsan_disk in $vsan_disks) { | |
$i++ | |
$vsan_disk | Select-Object @{N="vSAN_Disk_No";E={$i}},* | |
} | |
$vsan_diskgroups | Format-Table -AutoSize | Out-String -Width 150 | |
$vsan_disks | Format-Table -AutoSize | Out-String -Width 150 | |
# CSV output | |
$vsan_diskgroups | Export-Csv -Encoding utf8 -NoTypeInformation -Path $report_csv_file_name_1 | |
$vsan_disks | Export-Csv -Encoding utf8 -NoTypeInformation -Path $report_csv_file_name_2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
動作環境
使用方法