Merge pull request #75 from lamw/master

Adding vSAN Mgmt 6.x PowerCLI samples
This commit is contained in:
Kyle Ruddy authored and GitHub committed 2017-04-20 22:24:59 -04:00
commit bc9c52d50b
2 files changed
+85

No files matched your search

+59
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
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
}