Skip to content

Commit bc9c52d

Browse files
authored
Merge pull request #75 from lamw/master
Adding vSAN Mgmt 6.x PowerCLI samples
2 parents 29578c6 + a3c91c6 commit bc9c52d

File tree

2 files changed

+85
-0
lines changed

2 files changed

+85
-0
lines changed

Scripts/VSANSmartsData.ps1

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
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 "`nESXi 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+
}

Scripts/VSANVersion.ps1

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
Function Get-VSANVersion {
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 the vSAN software version for both VC/ESXi
12+
.PARAMETER Cluster
13+
The name of a vSAN Cluster
14+
.EXAMPLE
15+
Get-VSANVersion -Cluster VSAN-Cluster
16+
#>
17+
param(
18+
[Parameter(Mandatory=$true)][String]$Cluster
19+
)
20+
$vchs = Get-VSANView -Id "VsanVcClusterHealthSystem-vsan-cluster-health-system"
21+
$cluster_view = (Get-Cluster -Name $Cluster).ExtensionData.MoRef
22+
$results = $vchs.VsanVcClusterQueryVerifyHealthSystemVersions($cluster_view)
23+
24+
Write-Host "`nVC Version:"$results.VcVersion
25+
$results.HostResults | Select Hostname, Version
26+
}

0 commit comments

Comments
 (0)