Adding vSAN Mgmt 6.x PowerCLI samples
This commit is contained in:
59
Scripts/VSANSmartsData.ps1
Normal file
59
Scripts/VSANSmartsData.ps1
Normal 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
26
Scripts/VSANVersion.ps1
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user