forked from jasemccarty/Vsan-Settings
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathVsan-SetTsoLro.ps1
124 lines (94 loc) · 3.67 KB
/
Vsan-SetTsoLro.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<#==========================================================================
Script Name: Vsan-SetTsoLro.ps1
Created on: 12/15/2016
Created by: Jase McCarty
Github: http://www.github.com/jasemccarty
Twitter: @jasemccarty
Website: http://www.jasemccarty.com
===========================================================================
.DESCRIPTION
This script sets TSO/LRO Settings for Physical NICs
KB 2126909
PSOD w/ESXi 5.x/6.5 when using Intel X710 NICs
https://kb.vmware.com/kb/2126909
Syntax is:
To enable/disable TSO/LRO on pNics
Vsan-SetTsoLro.ps1 -VIServer <vCenter/ESXiHost> -TSOLRO <enable/disable> -ClusterName <ClusterName>
.Notes
#>
# Set our Parameters
[CmdletBinding()]Param(
[Parameter(Mandatory=$True)]
[string]$VIServer,
[Parameter(Mandatory=$False)]
[string]$ClusterName,
[Parameter(Mandatory = $true)]
[ValidateSet('enable','disable')]
[String]$TSOLRO
)
# Check to ensure we have either enable or disable, and set our values/text
Switch ($TSOLRO) {
"disable" {
$TSOLROVALUE = "0"
$TSOLROTEXT = "TSO/LRO is Disabled"
}
"enable" {
$TSOLROVALUE = "1"
$TSOLROTEXT = "TSO/LRO is Enabled"
}
default {
write-host "Please include the parameter -TSOLRO enable or -TSOLRO disabled"
exit
}
}
function SetTsoLro{
Param ([string]$ESXHost,[String]$TSOLRO)
# Get the Host
$ESXHost = $VIServer
$TSOState = Get-AdvancedSetting -Entity $ESXHost -Name "Net.UseHwTSO"
$TSO6State = Get-AdvancedSetting -Entity $ESXHost -Name "Net.UseHwTSO6"
$LROState = Get-AdvancedSetting -Entity $ESXHost -Name "Net.TcpipDefLROEnabled"
# 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($TSOState.value -ne $TSOLROVALUE -or $TSO6State.value -ne $TSOLROVALUE -or $LROState.value -ne $TSOLROVALUE){
# Show that host is being updated
Write-Host "On $ESXHost $TSOLROTEXT" -foregroundcolor red -backgroundcolor white
$TSOState | Set-AdvancedSetting -Value $TSOLROVALUE -Confirm:$false
$TSO6State | Set-AdvancedSetting -Value $TSOLROVALUE -Confirm:$false
$LROState | Set-AdvancedSetting -Value $TSOLROVALUE -Confirm:$false
Write-Host "A reboot of host $ESXHost is required for the updates to take effect" -foregroundcolor white -backgroundcolor red
}
Write-Host " "
}
Connect-VIServer $VIServer
# Grab the VIServer Type. "vpx" is vCenter. ESXi may be embeddedEsx or similar.
$VIServerType = $defaultviserver.ProductLine
# Depending on the which we've connected to, we'll want to operate differently
Switch ($VIServerType) {
# If the VIServer Type is "vpx" we've connected to vCenter
"vpx" {
# If the ClusterName parameter was passed, proceed
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 Name)){
# Execute the funtion to get/set the TSO/LRO settings
SetTsoLro -ESXHost $ESXHost -TSOLRO $TSOLRO
}
# If the ClusterName parameter was not passed, don't proceed.
} else {
Write-Host "When connected to a vCenter Server, a Cluster Name is required" -foregroundcolor red -backgroundcolor white
Write-Host "Please rerun this script with the -ClusterName parameter" -foregroundcolor red -backgroundcolor white
Exit
}
}
# If not connecting to a vCenter Server, simply run the function against the host
default {
# Execute the funtion to get/set the TSO/LRO settings
SetTsoLro -ESXHost $ESXHost -TSOLRO $TSOLRO
}
}