-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSetLSOMHeapSize.ps1
74 lines (56 loc) · 2.37 KB
/
SetLSOMHeapSize.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<#==========================================================================
Script Name: SetLSOMHeapSize.ps1
Created on: 3 SEP 2019
Created by: Jase McCarty
Github: http://www.github.com/jasemccarty
Twitter: @jasemccarty
Website: http://www.jasemccarty.com
===========================================================================
.DESCRIPTION
This script sets LSOM Heap Size Settings for ESXi Hosts, per KB Article: https://kb.vmware.com/kb/2150566
Syntax is:
SetLSOMHeapSize.ps1 -VIServer <vCenter/ESXiHost> -HeapSize <value> -ClusterName <ClusterName>
.Notes
#>
# Set our Parameters
[CmdletBinding()]Param(
[Parameter(Mandatory=$True)]
[string]$VIServer,
[Parameter(Mandatory=$False)]
[string]$ClusterName,
[Parameter(Mandatory = $true)]
[ValidateSet(256,1023,2047)]
[Int]$HeapSize
)
Function SetLSOMHeapSize{
Param ([string]$ESXHost,[Int]$HeapSizeVal)
$CurrentHeapSize = Get-AdvancedSetting -Entity $ESXHost -Name "LSOM.heapSize"
# Display the Host this is being performed on
Write-Host "Host:" $ESXHost
# If any of these are set to the opposite, toggle the setting
If($CurrentHeapSize.value -ne $HeapSize){
# Show that host is being updated
Write-Host "On $ESXHost the LSOM Heap Size is $CurrentHeapSize " -foregroundcolor red -backgroundcolor white
$CurrentHeapSize | Set-AdvancedSetting -Value $HeapSize -Confirm:$false
Write-Host "A reboot of host $ESXHost is required for the updates to take effect" -foregroundcolor white -backgroundcolor red
} else {
Write-Host "On $ESXHost the LSOM Heap Size is already set to $HeapSize" -ForegroundColor green
Write-Host "A reboot of host $ESXHost is not required as no updates have been made" -foregroundcolor green
}
Write-Host " "
}
# If the ClusterName variable is passed, it is expected that the Server used will be a vCenter Server
If ($ClusterName) {
# Get the Cluster Name
$Cluster = Get-Cluster -Name $ClusterName -ErrorAction SilentlyContinue
# Display the Cluster
Write-Host Cluster: $($Cluster.name)
# Cycle through each ESXi Host in the cluster
Foreach ($ESXHost in ($Cluster |Get-VMHost | Sort-Object "Name")){
# Execute the funtion to get/set the Rx Dispatch Queue settings
SetLSOMHeapSize -ESXHost $ESXHost -HeapSize $HeapSize
}
} else {
# Execute the funtion to get/set the LSOM Heap Size settings
SetLSOMHeapSize -ESXHost (Get-VMHost $VIServer) -HeapSize $HeapSize
}