Adding vSAN Mgmt 6.x PowerCLI samples

This commit is contained in:
William Lam
2017-04-20 17:47:31 -07:00
parent 492f89cc91
commit a3c91c6376
2 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,59 @@
Function Get-VSANSmartsData {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function retreives SMART drive data using new vSAN
Management 6.6 API. This can also be used outside of vSAN
to query existing SSD devices not being used for vSAN.
.PARAMETER Cluster
The name of a vSAN Cluster
.EXAMPLE
Get-VSANSmartsData -Cluster VSAN-Cluster
#>
param(
[Parameter(Mandatory=$false)][String]$Cluster
)
if($global:DefaultVIServer.ExtensionData.Content.About.ApiType -eq "VirtualCenter") {
if(!$cluster) {
Write-Host "Cluster property is required when connecting to vCenter Server"
break
}
$vchs = Get-VSANView -Id "VsanVcClusterHealthSystem-vsan-cluster-health-system"
$cluster_view = (Get-Cluster -Name $Cluster).ExtensionData.MoRef
$result = $vchs.VsanQueryVcClusterSmartStatsSummary($cluster_view)
} else {
$vhs = Get-VSANView -Id "HostVsanHealthSystem-ha-vsan-health-system"
$result = $vhs.VsanHostQuerySmartStats($null,$true)
}
$vmhost = $result.Hostname
$smartsData = $result.SmartStats
Write-Host "`nESXi Host: $vmhost`n"
foreach ($data in $smartsData) {
if($data.stats) {
$stats = $data.stats
Write-Host $data.disk
$smartsResults = @()
foreach ($stat in $stats) {
$statResult = [pscustomobject] @{
Parameter = $stat.Parameter;
Value =$stat.Value;
Threshold = $stat.Threshold;
Worst = $stat.Worst
}
$smartsResults+=$statResult
}
$smartsResults | Format-Table
}
}
}

26
Scripts/VSANVersion.ps1 Normal file
View File

@@ -0,0 +1,26 @@
Function Get-VSANVersion {
<#
.NOTES
===========================================================================
Created by: William Lam
Organization: VMware
Blog: www.virtuallyghetto.com
Twitter: @lamw
===========================================================================
.DESCRIPTION
This function retreives the vSAN software version for both VC/ESXi
.PARAMETER Cluster
The name of a vSAN Cluster
.EXAMPLE
Get-VSANVersion -Cluster VSAN-Cluster
#>
param(
[Parameter(Mandatory=$true)][String]$Cluster
)
$vchs = Get-VSANView -Id "VsanVcClusterHealthSystem-vsan-cluster-health-system"
$cluster_view = (Get-Cluster -Name $Cluster).ExtensionData.MoRef
$results = $vchs.VsanVcClusterQueryVerifyHealthSystemVersions($cluster_view)
Write-Host "`nVC Version:"$results.VcVersion
$results.HostResults | Select Hostname, Version
}