Quantcast
Viewing latest article 15
Browse Latest Browse All 29

How to find MTU on a list of Windows Servers, using PowerShell ?

# This script can be used to find MTU size on a list of servers. Choose FQDN or make sure all servers are accessible using server name. # Get-NetIPInterface  is part of PowerShell module NetTCPIP, and should work for all servers with PowerShell v3+, though this is not tested.# Any errors will be displayed in the console window.

$servers = Get-Content "D:\temp\all-servers.txt
@(
foreach ($name in $servers) 
{ 
 if ( Test-Connection -ComputerName $name -Count 1 -ErrorAction SilentlyContinue )
 {
 $var1 = New-PSSession -ComputerName $name
 Invoke-Command -Session $var1 -ScriptBlock { Get-NetIPInterface | where {($_.AddressFamily -eq "IPv4") -and ($_.NlMtu -lt 10000)} | select NlMtu, interfacealias, pscomputername } | ft -a
 #Invoke-Command -Session $var1 -ScriptBlock { netsh interface ipv4 show subinterface} | fl *       #we can use this line using netsh as an alternative to the invoke-command in the above line
 sleep 5
 $var1 | Remove-PSSession #this will remove/close all existing ps sessions
 $var1 = $null
 }
 else
 {
 Write "$name is not pinging/not accessible"
 }
}) | out-file "D:\temp\MTU-all-servers-1.csv"

#script ends here#


Viewing latest article 15
Browse Latest Browse All 29

Trending Articles