Enhance adapter status and IP display in Get-AdapterChoice function
This commit is contained in:
parent
7b4176a7eb
commit
905789c3ad
1 changed files with 17 additions and 2 deletions
|
|
@ -46,8 +46,23 @@ function Get-AdapterChoice {
|
|||
$macLinux = $macWindows -replace '-', ':'
|
||||
|
||||
Write-Host "$index. $($adapter.Name)" -ForegroundColor White
|
||||
Write-Host " $($adapter.InterfaceDescription) $status" -ForegroundColor Gray
|
||||
Write-Host " IP: $ipAddress | MAC: $macWindows ($macLinux)" -ForegroundColor Cyan
|
||||
|
||||
# Colored description + status
|
||||
$statusLabel = if ($adapter.Status -eq 'Up') { 'CONNECTED' } else { $adapter.Status.ToUpper() }
|
||||
if ($adapter.Status -eq 'Up') { $statusColor = 'Green' }
|
||||
elseif ($adapter.Status -in @('Down','NotPresent','Not Present')) { $statusColor = 'Red' }
|
||||
else { $statusColor = 'Yellow' }
|
||||
|
||||
Write-Host " $($adapter.InterfaceDescription) " -ForegroundColor Gray -NoNewline
|
||||
Write-Host "[$statusLabel]" -ForegroundColor $statusColor
|
||||
|
||||
# Colored IP and MAC display
|
||||
if ($ipv4) {
|
||||
Write-Host " IP: $ipAddress" -ForegroundColor Cyan -NoNewline
|
||||
} else {
|
||||
Write-Host " IP: No IP" -ForegroundColor DarkYellow -NoNewline
|
||||
}
|
||||
Write-Host " | MAC: $macWindows ($macLinux)" -ForegroundColor DarkGray
|
||||
$index++
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue