From 905789c3ad7143bdb249951f42329d79a3cbdd9b Mon Sep 17 00:00:00 2001 From: Maddo Date: Thu, 12 Feb 2026 01:08:48 +0100 Subject: [PATCH] Enhance adapter status and IP display in Get-AdapterChoice function --- Set-NetworkAdapter.ps1 | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/Set-NetworkAdapter.ps1 b/Set-NetworkAdapter.ps1 index f8b6e23..c37bcd4 100644 --- a/Set-NetworkAdapter.ps1 +++ b/Set-NetworkAdapter.ps1 @@ -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++ }