[CmdletBinding()] param( [switch]$IncludeDisconnected ) $ErrorActionPreference = 'Stop' try { $adapters = @(Get-NetAdapter -ErrorAction Stop) } catch { throw "Не удалось получить сетевые адаптеры: $($_.Exception.Message)" } if (-not $IncludeDisconnected) { $adapters = @($adapters | Where-Object { $_.Status -eq 'Up' }) } $rows = foreach ($adapter in $adapters) { $stats = Get-NetAdapterStatistics -Name $adapter.Name -ErrorAction SilentlyContinue [pscustomobject]@{ Name = $adapter.Name Status = $adapter.Status SpeedMbps = $(if ($adapter.LinkSpeed) { [math]::Round($adapter.LinkSpeed / 1e6, 0) } else { 0 }) Mac = $adapter.MacAddress Mtu = $adapter.MtuSize RxMB = $(if ($stats) { [math]::Round($stats.ReceivedBytes / 1MB, 2) } else { 0 }) TxMB = $(if ($stats) { [math]::Round($stats.SentBytes / 1MB, 2) } else { 0 }) } } if ($rows.Count -eq 0) { Write-Host "Подключённых адаптеров нет" exit 1 } $rows | Sort-Object Name | Format-Table -AutoSize Write-Host "Адаптеров: $($rows.Count)"