1
+ Function Get-VSANSmartsData {
2
+ <#
3
+ . NOTES
4
+ ===========================================================================
5
+ Created by: William Lam
6
+ Organization: VMware
7
+ Blog: www.virtuallyghetto.com
8
+ Twitter: @lamw
9
+ ===========================================================================
10
+ . DESCRIPTION
11
+ This function retreives SMART drive data using new vSAN
12
+ Management 6.6 API. This can also be used outside of vSAN
13
+ to query existing SSD devices not being used for vSAN.
14
+ . PARAMETER Cluster
15
+ The name of a vSAN Cluster
16
+ . EXAMPLE
17
+ Get-VSANSmartsData -Cluster VSAN-Cluster
18
+ #>
19
+ param (
20
+ [Parameter (Mandatory = $false )][String ]$Cluster
21
+ )
22
+
23
+ if ($global :DefaultVIServer.ExtensionData.Content.About.ApiType -eq " VirtualCenter" ) {
24
+ if (! $cluster ) {
25
+ Write-Host " Cluster property is required when connecting to vCenter Server"
26
+ break
27
+ }
28
+
29
+ $vchs = Get-VSANView - Id " VsanVcClusterHealthSystem-vsan-cluster-health-system"
30
+ $cluster_view = (Get-Cluster - Name $Cluster ).ExtensionData.MoRef
31
+ $result = $vchs.VsanQueryVcClusterSmartStatsSummary ($cluster_view )
32
+ } else {
33
+ $vhs = Get-VSANView - Id " HostVsanHealthSystem-ha-vsan-health-system"
34
+ $result = $vhs.VsanHostQuerySmartStats ($null , $true )
35
+ }
36
+
37
+ $vmhost = $result.Hostname
38
+ $smartsData = $result.SmartStats
39
+
40
+ Write-Host " `n ESXi Host: $vmhost `n "
41
+ foreach ($data in $smartsData ) {
42
+ if ($data.stats ) {
43
+ $stats = $data.stats
44
+ Write-Host $data.disk
45
+
46
+ $smartsResults = @ ()
47
+ foreach ($stat in $stats ) {
48
+ $statResult = [pscustomobject ] @ {
49
+ Parameter = $stat.Parameter ;
50
+ Value = $stat.Value ;
51
+ Threshold = $stat.Threshold ;
52
+ Worst = $stat.Worst
53
+ }
54
+ $smartsResults += $statResult
55
+ }
56
+ $smartsResults | Format-Table
57
+ }
58
+ }
59
+ }
0 commit comments