Skip to content

Instantly share code, notes, and snippets.

@takekazuomi
Created April 24, 2014 13:07
Show Gist options
  • Save takekazuomi/11253981 to your computer and use it in GitHub Desktop.
Save takekazuomi/11253981 to your computer and use it in GitHub Desktop.
# TCP tune script
function SetPropertyDWORD([string]$path, [string]$key, [string]$Value) {
$oldValue = "0x{0:X}" -f (Get-ItemProperty -path $path).$key
if($Value -eq $oldValue)
{
return $false;
}
Set-ItemProperty -path $path -name $key -Type DWORD -Value $Value
$newValue = (Get-ItemProperty -path $path).$key
$data = "$path\$key=$oldValue"
Write-Output "Value for $path\$key changed from $oldValue to $newValue"
return $true
}
$path = "HKLM:\System\CurrentControlSet\Services\Tcpip\Parameters"
$updated = SetPropertyDWORD $path "TcpTimedWaitDelay" 0x1e
if($updated)
{
netsh int ipv4 set dynamicport tcp start=1025 num=64511
Write-Host -Object $(Get-Date), "reboot"
Restart-Computer
}
else
{
Write-Host -Object $(Get-Date), "no reboot"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment