Enhance adapter status and IP display in Get-AdapterChoice function

This commit is contained in:
Maddo 2026-02-12 01:08:48 +01:00
commit 905789c3ad

View file

@ -46,8 +46,23 @@ function Get-AdapterChoice {
$macLinux = $macWindows -replace '-', ':' $macLinux = $macWindows -replace '-', ':'
Write-Host "$index. $($adapter.Name)" -ForegroundColor White 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++ $index++
} }