@@ -5,6 +5,8 @@ machine. All other adpaters such as tunneling and loopbacks are ignored. Only
5
5
adapters are considered.
6
6
#>
7
7
8
+ param ([switch ] $verbose )
9
+
8
10
$preferred = $null
9
11
10
12
$items = @ ()
@@ -18,8 +20,10 @@ if ([Net.NetworkInformation.NetworkInterface]::GetIsNetworkAvailable())
18
20
Address = $null
19
21
DNSServer = $null
20
22
Gateway = $null
21
- Description = $null
22
- HasStats = $false
23
+ Description = $null
24
+ DnsSuffix = $null
25
+ BytesReceived = 0
26
+ BytesSent = 0
23
27
Status = $_.OperationalStatus
24
28
Type = $_.NetworkInterfaceType
25
29
}
@@ -39,15 +43,21 @@ if ([Net.NetworkInformation.NetworkInterface]::GetIsNetworkAvailable())
39
43
| select - first 1 - ExpandProperty Address
40
44
41
45
$stats = $_.GetIPv4Statistics () | Select - first 1
42
- $item.HasStats = ($stats.BytesReceived -gt 0 ) -and ($stats.BytesSent -gt 0 )
46
+ $item.BytesReceived = $stats.BytesReceived
47
+ $item.BytesSent = $stats.BytesSent
43
48
44
- $item.Description = $_.Name + ' , ' + $_.Description
49
+ $item.Description = $_.Name + ' , ' + $_.Description
50
+ $item.DnsSuffix = $props.DnsSuffix
45
51
if (($props.DnsSuffix -ne $null ) -and ($props.DnsSuffix.Length -gt 0 ))
46
52
{
47
53
if ($item.Type.ToString ().StartsWith(' Wireless' ))
48
54
{
49
- $profile = (netsh wlan show interfaces | Select-String ' \sSSID' ).ToString().Split(' :' )[1 ].Trim()
50
- if ($profile ) { $item.Description += (' , ' + $profile ) }
55
+ $ssid = netsh wlan show interfaces | Select-String ' \sSSID'
56
+ if ($ssid )
57
+ {
58
+ $profile = $ssid.ToString ().Split(' :' )[1 ].Trim()
59
+ if ($profile ) { $item.Description += (' , ' + $profile ) }
60
+ }
51
61
}
52
62
else
53
63
{
@@ -94,7 +104,22 @@ if ([Net.NetworkInformation.NetworkInterface]::GetIsNetworkAvailable())
94
104
}
95
105
else {
96
106
Write-Host $line
97
- }
107
+ }
108
+
109
+ if ($verbose )
110
+ {
111
+ if ($_.Status -eq ' Up' )
112
+ {
113
+ Write-Host (" {0,47} Type{1} BytesSent:{2} BytesReceived:{3}" -f `
114
+ ' ' , $_.Type , $_.BytesSent , $_.BytesReceived ) - ForegroundColor DarkGray
115
+
116
+ if ($_.DnsSuffix )
117
+ {
118
+ Write-Host (" {0,47} DnsSuffix:{1}" -f ' ' , $_.DnsSuffix ) - ForegroundColor DarkGray
119
+ }
120
+ }
121
+ Write-Host
122
+ }
98
123
}
99
124
}
100
125
else
0 commit comments