VMware Cloud Community
Tibmeister
Expert
Expert

PowerCLI to set Capacity Thresholds of vSAN Cluster

So in the vSphere Client, under Cluster > Configure > vSAN > Services > Reservations and Alerts, there is an option to Customize Alerts.  I have tried the Code Capture but nothing is there, and I'm hoping someone has some obscure piece of code, using a view or something, to be able to set this programmatically.

1 Reply
SOttavi
VMware Employee
VMware Employee

I know this post has been up for a while, but I needed to find a solution and decided to share in case anyone ever needs to automate this.

** You need powerCli 13.0 + **

To find the setting: 
Get-Cluster myClusterName | Get-VsanClusterConfiguration | select -ExpandProperty CapacityThreshold

Example:

PS C:\Windows\system32> Get-Cluster wl-cluster01 |Get-VsanClusterConfiguration |select -ExpandProperty CapacityThreshold

Enabled RedValue YellowValue Target
-------     --------       -----------      ------
True      85             75                VsanDatastore

To enable and change the value:

Get-Cluster myClsuter |Set-VsanClusterConfiguration -CapacityThreshold (New-VsanHealthCheckThreshold -Enabled $true -RedValue 85 -YellowValue 75 -Target VsanDatastore)

Get-Cluster wl-cluster01 |Set-VsanClusterConfiguration -CapacityThreshold (New-VsanHealthCheckThreshold -Enabled $true -RedValue 85 -YellowValue 75 -Target VsanDatastore)

Cluster VsanEnabled IsStretchedCluster Last HCL Updated
------- ----------- ------------------ ----------------
wl-cluster01 True False 2023-02-22 8:00:00 AM

Hope this helps!