Pages

Friday, January 24, 2014

Powershell to run NetSH

We had an issue recently where our hardware team gave us servers with newer network drivers. As part of the default settings on these drivers, the MTU size was increased to 1514. This cause inconsistent packet loss on our servers. This became evident when we tried moving large numbers of users to these servers and the logs couldn't replicate between the users. To resolve it, we had to logon to each of the servers, and reduce the packet size from 1514, down to 1500 (the former driver values).

This scrip grabs the values from NETSH and then processes it to see if it's set to 1500 or 1514. If not 1500, it sets the interface to 1500.


$a = netsh int ipv4 sho int
$a 
$maxNic = $a.count
for ($i=3;$i -lt $maxNic-1;$i++) { 
 $nic = ($a[$i].split(" ") | ?{!$_ -eq ""})
 if ([double]$nic[2] -eq 1500) {
  write-host "investigate $nic[4]" -foreground Yellow
  Netsh int ipv4 set subinterface $nic[0] mtu=1500 store=persistent
 }
}

No comments:

Post a Comment