Created
April 24, 2014 13:07
-
-
Save takekazuomi/11253981 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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