Get-NetworkAdapterConnectionStatus: Unterschied zwischen den Versionen
Aus Wiki-WebPerfect
Admin (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „<source lang="powershell"> Function Get-NetworkConnectionStatus { param( $ComputerName=$env:computername ) $statushash = @{ 0 = "D…“) |
Admin (Diskussion | Beiträge) |
||
Zeile 34: | Zeile 34: | ||
+ | ''Source: https://techibee.com/powershell/powershell-get-network-adapter-connection-status/1143'' | ||
− | + | ||
+ | |||
+ | |||
+ | [[Kategorie:PowerShell]] |
Version vom 9. Januar 2019, 10:20 Uhr
Function Get-NetworkConnectionStatus { param( $ComputerName=$env:computername ) $statushash = @{ 0 = "Disconnected" 1 = "Connecting" 2 = "Connected" 3 = "Disconnecting" 4 = "Hardware not present" 5 = "Hardware disabled" 6 = "Hardware malfunction" 7 = "Media Disconnected" 8 = "Authenticating" 9 = "Authentication Succeeded" 10 = "Authentication Failed" 11 = "Invalid Address" 12 = "Credentials Required" } $networks = Gwmi -Class Win32_NetworkAdapter -ComputerName $computername $networkName = @{name="NetworkName";Expression={$_.Name}} $networkStatus = @{name="Networkstatus";Expression=` {$statushash[[int32]$($_.NetConnectionStatus)]}} foreach ($network in $networks) { $network | select $networkName, $Networkstatus } }
Source: https://techibee.com/powershell/powershell-get-network-adapter-connection-status/1143