2010-06-09 9 views

risposta

8

Un comando di base è

Get-WmiObject -ComputerName 'servername' -Class Win32_NetworkAdapter | ` 
    Where-Object { $_.Speed -ne $null -and $_.MACAddress -ne $null } | ` 
    Format-Table -Property SystemName,Name,NetConnectionID,Speed 

Nota che il parametro ComputerName accetta un array in modo da poter eseguire questo contro più computer purché si disponga di diritti. Sostituisci l'elenco delle proprietà Format-Table con ***** per ottenere un elenco più completo delle proprietà disponibili. Potresti voler filtrare queste proprietà per eliminare le voci che non ti interessano.

Utilizzare il byte integrato I suffissi del moltiplicatore (MB, GB ecc.) Renderebbero anche la velocità più leggibile a seconda delle esigenze. È possibile specificare questo come una voce HashTable nella tabella Format-Table -Property, ad es.

Format-Table -Property NetConnectionID,@{Label='Speed(GB)'; Expression = {$_.Speed/1GB}} 
+0

Una bella risposta! Rimuoverei le parti '-ne $ null'. –

+0

Ci sono in realtà alcune voci restituite per la classe Win32_NetworkAdapter, check it out. Sto usando il -ne $ null per filtrare le voci in modo da poter vedere le voci effettive per le carte fisiche reali ma puoi adattare come meglio credi. –

+0

[System.Net.NetworkInformation.NetworkInterface] :: GetAllNetworkInterfaces() funziona solo contro la macchina locale. –

0

La mia versione corrente, tirando fuori bluetooth e wireless carte (eseguito con PowerShell -file script.ps1):

# return network speed as exit code 

$speed = Get-WmiObject -Class Win32_NetworkAdapter | 
where { $_.speed -and $_.macaddress -and 
$_.name -notmatch 'wireless|wi-fi|bluetooth|802\.11' } | select -expand speed 
exit $speed/1000000 
Problemi correlati