þÿ# File Name: Set-JumboFrame.ps1 # ======================================================== # Created: March 24, 2010 # Version: 1.1 # Author: Matthew H. Mattoon # Website: http://blog.allanglesit.com # ======================================================== # Purpose: Allows enabling/disabling of Jumbo Frames # settings automatically # PreReqs: 1) Interface must have a Static IP. # 2) To enable on a Hyper-V Virtual Switch # the Switch must not be created. # ======================================================== # Examples: .\set-jumboframe.ps1 <Mode> <IP> # .\set-jumboframe.ps1 enable 10.0.0.1 # .\set-jumboframe.ps1 disable 10.0.0.1 # .\set-jumboframe.ps1 verify 10.0.0.1 # ======================================================== # v1.0 > v1.1 - March 29, 2010 # 1) $FindAdapterProperties now only checks registry keys # for registry keys preceeded by a zero # 2) Added color to the Write-Hosts # ======================================================== param([string]$Mode = $(throw "Please specify enable, disable, or verify"), [string]$IPAddress = $(Read-Host -prompt "Enter the Static IP of the NIC to work with")) Function VerifyJumboFrames ($IpAddress,$AdapterName,$CurrentJumboPacket) { Write-Host -foregroundcolor yellow $IpAddress on $AdapterName currently has a MTU size of $CurrentJumboPacket } Function EnableJumboFrames ($IpAddress,$AdapterName,$CurrentJumboPacket,$AdapterProperties) { $EnableRegJumboPacket = 9014 $EnableCmdJumboPacket = "mtu=9000" Write-Host -foregroundcolor yellow $IpAddress on $AdapterName currently has a MTU size of $CurrentJumboPacket Write-Host -foregroundcolor cyan Modifying netsh MTU Settings... netsh interface ipv4 set subinterface $AdapterName $EnableCmdJumboPacket store=persistent Write-Host -foregroundcolor cyan Modifying Registry MTU Settings... Set-ItemProperty $AdapterProperties.PSPath -name "*JumboPacket" -value $EnableRegJumboPacket Write-Host -foregroundcolor red Enable Completed - Reboot is Required. } Function DisableJumboFrames ($IpAddress,$AdapterName,$CurrentJumboPacket,$AdapterProperties) { $DisableRegJumboPacket = 1514 $DisableCmdJumboPacket = "mtu=1500" Write-Host -foregroundcolor yellow $IpAddress on $AdapterName currently has a MTU size of $CurrentJumboPacket Write-Host -foregroundcolor cyan Modifying Registry MTU Settings... Set-ItemProperty $AdapterProperties.PSPath -name "*JumboPacket" -value $DisableRegJumboPacket Write-Host -foregroundcolor cyan Modifying netsh MTU Settings... netsh interface ipv4 set subinterface $AdapterName $DisableCmdJumboPacket store=persistent Write-Host -foregroundcolor red Disable Completed - Reboot is Required. } $FindInterfaceIndex = gwmi win32_networkAdapterConfiguration |where {$_.IPAddress -eq $IpAddress} $FindInterfaceGUID = gwmi win32_networkAdapter |where {$_.Index -eq $FindInterfaceIndex.Index} $GUID = $FindInterfaceGUID.GUID $FindAdapterName = Get-ItemProperty "HKLM:\SYSTEM\CurrentControlSet\Control\Network\{4D36E972-E325-11CE-BFC1-08002BE10318}\$GUID\Connection" $AdapterName = $FindAdapterName.Name ## Legacy Code v1.0 $FindAdapterProperties = Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\*\' |where {$_.NetCfgInstanceID -eq $guid} $FindAdapterProperties = Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Class\{4D36E972-E325-11CE-BFC1-08002BE10318}\0*\' |where {$_.NetCfgInstanceID -eq $guid} $AdapterProperties = Get-ItemProperty $FindAdapterProperties.PSPath $CurrentJumboPacket = $AdapterProperties."*JumboPacket" if ($Mode -eq "enable") { EnableJumboFrames $IpAddress $AdapterName $CurrentJumboPacket $AdapterProperties } elseif ($Mode -eq "disable") { DisableJumboFrames $IpAddress $AdapterName $CurrentJumboPacket $AdapterProperties } elseif ($Mode -eq "verify") { VerifyJumboFrames $IpAddress $AdapterName $CurrentJumboPacket }