Results in PSObject array of all NIC's
Computername NicName LinkSpeed Collisions ------------ ------- --------- ---------- MyComputer Intel(R) PRO/100... 100 0
function get-NicError ([string]$server) { #This function uses WMI queries against the target machine to get link speed information and #check for any recorded network collissions. It combines the two queries to print out collisions #per adapter with link speed. if ([string]::IsNullOrEmpty($server)) { write-host -foregroundcolor "yellow" "Usage: get-NicError servername" write-host -foregroundcolor "yellow" " Get speed and collision details for network adapters" return } $result = @() $a = gwmi -namespace root\wmi -class msndis_ethernetmoretransmitcollisions -computername $server |select-object instancename,ndisethernetmoretransmitcollisions $b = gwmi -namespace root\wmi -class msndis_linkspeed -computername $server | select-object instancename,ndislinkspeed if (($a -eq $null) -or ($b -eq $null)) { write-error "WMI connection error" return } foreach ($link in $b) { $link.ndislinkspeed = $link.ndislinkspeed / 10000 } foreach ($item in $a) { foreach ($seconditem in $b) { if ($item.instancename -eq $seconditem.instancename) { $myres = New-Object psobject Add-Member -InputObject $myres NoteProperty Computername $server Add-Member -InputObject $myres Noteproperty NicName $item.instancename Add-Member -InputObject $myres Noteproperty LinkSpeed $seconditem.ndislinkspeed Add-Member -InputObject $myres Noteproperty Collisions $item.ndisethernetmoretransmitcollisions $result += $myres } } } return $result }
No comments:
Post a Comment