Recently, there has been an increase in Office 365 migrations failing due to a simple setting that is often overlooked.
<!– wp:rank-math/toc-block {"headings":[{"key":"5f2eb3f2-3651-41e3-9f50-04ddeabbc7e7","content":"Exchange Server TCP Keep Alive Time What is it?”,”level”:2,”link”:”#exchange-server-tcp-keep-alive-time-nedir”,”disable”:false,”isUpdated”:false,”isGeneratedLink”:true}, {“key”:”fbe84a95-6ca2-46e3-9c49-60d8843569d3″,”content”:”TCP Keep Alive Time Configuration”,”level”:2,”link”:”#tcp-keep-alive-time-configuration”,”disable”:false,”isUpdated”:false,”isGeneratedLink”:true}],”listStyle”: ”ul”} –>What is Exchange Server TCP Keep Alive Time?
TCP Keep Alive Time is known as TCP/IP parameter used to keep a request connected in Exchange Server. This parameter is used to keep TCP connection active when there is no data request for a certain period of time.
That is, when a connection between a client and server has been silent for a period of time, the TCP Keep Alive mechanism kicks in and sends a small control packet to verify that the connection is still open. If no response is received, the connection request is terminated.
TCP KeepAliveTime value determines how often these control packets are sent. This period is usually a default value determined by the system, but can be adjusted according to the user's needs. This setting is especially important for situations where the connection must not be interrupted even if there is no continuous data exchange over the network.
For example, remote terminal sessions, database connections, and other long-term TCP sessions.
Configuring TCP Keep Alive Time
TCP KeepAliveTime If the setting is not set correctly, the default time of 2 hours is used. However, network equipment often sets this time to a shorter time.
Microsoft in your environment TCP KeepAliveTime to report the values and update them when necessary. TCP Keep Alive Time Report This scenario has been observed to be extremely useful, especially for large environments.
The script is a specific Active Directory when run on a site, all of the features specific to that site Exchange analyzes its servers.
The script is run Active Directory belongs to the site Exchange It queries the servers and produces a CSV report containing the status of the TCP KeepAliveTime registry key. This report indicates the names of the servers, whether the registry key exists, and if so, what value it has.
The script asks if you want to modify the registry keys. The default answer is "No". If you select "Yes", TCP KeepAliveTime You will be prompted to change the registry key, which defaults to 30 milliseconds for 1.800.000 minutes. If you want to enter your own value, only integers should be entered, and all times should be specified in milliseconds.
Note that servers must be restarted for changes to take effect. A time between 15 and 30 minutes is recommended, as setting the TCP Keep Alive Time value low can increase the CPU load on the server.
https://github.com/jojerd/TCPKeepAliveTimeReportScript
<#
.NOTES
Name: TCPKeepAliveTimeChecker.ps1
Author: Josh Jerdon
Email: [email protected]
Requires: PowerShell 3.0, Exchange Management Shell as well as administrator rights on the target Exchange
server.
Version History:
1.0 - 5/15/2017
1.01 - 6/28/2017 Fixed Foreach loop bug asking for KeepAliveTime Value for each server when changing multiple servers.
1.02 - 3/7/2018 Fixed PSSnapin load errors if script was executed more than once in a single PowerShell session. Also refined how script checks for PowerShell version.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
.SYNOPSIS
Checks all of the Exchange Servers within a given AD site and generates a report of it's findings,
namely if the TCP KeepAliveTime registry key exists and if so what the value is.
It also provides the functionality to modify the TCP Keep Alive Settings of all Exchange servers
in the local AD site. This is extremely useful in large Exchange organizations but should be used with
care.
#>
#Checking Powershell Version to Ensure Script Works as Intended
if ($PSVersionTable.PSVersion.Major -gt 3) {
Write-Host "PowerShell meets minimum version requirements, continuing" -ForegroundColor Green
Start-Sleep -Seconds 3
Clear-Host
#Add Exchange Management Capabilities Into The Current PowerShell Session.
$CheckSnapin = (Get-PSSnapin | Where {$_.Name -eq "Microsoft.Exchange.Management.PowerShell.E2010"} | Select Name)
if ($CheckSnapin -like "*Exchange.Management.PowerShell*") {
Write-Host "Exchange Snap-in already loaded, continuing...." -ForegroundColor Green
}
else {
Write-Host "Loading Exchange Snap-in Please Wait..."
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue
}
#Search local AD Site for all Exchange Servers.
$ADSite = [System.DirectoryServices.ActiveDirectory.ActiveDirectorySite]::GetComputerSite().Name
Write-Host "Searching Active Directory Site $ADSite for Exchange Servers, Please Wait..."
$Servers = Get-ExchangeServer | Where-Object {$_.Site -match $ADSite}
#File Output parameters for report output
$OutputFilePath = "."
$OutPutReportName = "TCPKeepAliveTimeReport" + "-" + (Get-Date).ToString("MMddyyyyHHmmss") + ".csv"
$OutPutFullReportPath = $OutputFilePath + "" + $OutPutReportName
if ($Servers.count -gt 0) {
#Connect to Each server that it finds from above and open the KeepAliveTime registry key if it exists and record the value.
foreach ($Server in $Servers) {
$EXCHServer = $Server.name
$OpenReg = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $EXCHServer)
$RegKeyPath = 'SYSTEMCurrentControlSetServicesTcpipParameters'
$RegKey = $OpenReg.OpenSubKey($RegKeyPath)
$TCPKeepAlive = $RegKey.GetValue('KeepAliveTime')
$Exists = if ($TCPKeepAlive) {$true} else {$false}
#Dump the scripts findings into an object.
$Report = [PSCustomObject]@{
"Server Name" = $EXCHServer;
"Key Present" = $Exists;
"TCP Keep Alive Time" = $TCPKeepAlive
}
#Write the output to a report file
$Report | Export-Csv ($OutPutFullReportPath) -Append -NoTypeInformation
}
}
else {
Write-Host "Found 0 Exchange Servers, Exiting Script..." -ForegroundColor Red
Write-Host " "
Write-Host " "
Write-Host "Press Any Key To Continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Exit
}
#Asks if you'd like to change the TCP Keep Alive Times.
Clear-Host
$Message = "Do You Want To Create And Or Modify The TCP KeepAliveTime Registry Key?"
$Yes = New-Object System.Management.Automation.Host.ChoiceDescription "&Yes", "help";
$No = New-Object System.Management.Automation.Host.ChoiceDescription "&No", "help";
$choices = [System.Management.Automation.Host.ChoiceDescription[]]($Yes, $no);
$answer = $host.UI.PromptForChoice($caption, $message, $choices, 1)
switch ($answer) {
0 {Write-Host "Continuing Script As You Have Confirmed That You Want To Create And Or Modify The TCP KeepAliveTime Registry Key"; Start-Sleep -Seconds 5}
1 {Write-Host "Exiting Script..."; exit}
}
Clear-Host
$TimeValue = Read-Host 'How Many Milliseconds Do You Want The TCP Keep Alive Time Set Too? (Default is 1,800,000ms (30 minutes)'
$DefaultValue = "1800000"
$KeyName = "KeepAliveTime"
Clear-Host
foreach ($Server in $Servers) {
$EXCHServer = $Server.name
$BaseKey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $EXCHServer)
$SubKey = $BaseKey.OpenSubkey("SYSTEMCurrentControlSetServicesTcpipParameters", $true)
if ($TimeValue) {
$SubKey.SetValue($KeyName, $TimeValue, [Microsoft.Win32.RegistryValueKind]::DWORD)
}
Else {
$SubKey.SetValue($KeyName, $DefaultValue, [Microsoft.Win32.RegistryValueKind]::DWORD)
}
}
Clear-Host
Write-Host 'Each Server That Had Its TCP Keep Alive Time Value Changed Will Require A Reboot For The Changes To Take Affect.' -ForegroundColor Green
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Exit
}
else {
Write-Host "PowerShell Version does not meet minimum requirements of at least 3.0, please update to at least PowerShell 3.0 and try again." -ForegroundColor Red
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Exit
}
Exit
After the relevant script runs, it also creates a CSV file containing the TCP Keep Alive Time values of all Exchange Servers in your environment. In this way, you can check the values of your entire environment.
2 thoughts on “Exchange Server TCP Keep Alive Time”