"#Requires -RunAsAdministrator" # Import module $scriptPath = Split-Path -Parent $PSCommandPath $modulePath = Join-Path $scriptPath 'NetworkAdapter.psm1' if (Test-Path $modulePath) { Import-Module $modulePath -Force } else { Write-Host "Module not found: $modulePath" -ForegroundColor Red Read-Host "Press Enter to exit" exit } # Main script try { # Check for administrator privileges $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) if (-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { Write-Host "This script requires administrator privileges!" -ForegroundColor Red Read-Host "Press Enter to exit" exit } do { # Select adapter $adapter = Get-AdapterChoice # If null returned (PATH option was selected), continue to show menu again if ($null -eq $adapter) { continue } do { # Show adapter information Show-AdapterInfo -Adapter $adapter # Show menu Write-Host "Options:" -ForegroundColor Yellow Write-Host "1. Set to DHCP (automatic)" -ForegroundColor White Write-Host "2. Set Manual IP Configuration" -ForegroundColor White Write-Host "3. Refresh Adapter Status" -ForegroundColor White Write-Host "4. Choose Different Adapter" -ForegroundColor White Write-Host "5. Presets (save/load)" -ForegroundColor White Write-Host "0. Exit" -ForegroundColor Gray Write-Host "" $choice = Read-Host "Select option" switch ($choice) { '1' { Set-DHCPConfiguration -Adapter $adapter } '2' { Set-ManualConfiguration -Adapter $adapter } '3' { # Refresh - just continue the loop to redisplay info Write-Host "Refreshing adapter status..." -ForegroundColor Yellow Start-Sleep -Milliseconds 500 } '4' { break } '5' { Show-PresetsMenu -Adapter $adapter } '0' { exit } default { Write-Host "Invalid option!" -ForegroundColor Red Start-Sleep -Seconds 1 } } } while ($choice -ne '4') } while ($true) } catch { Write-Host "An unexpected error occurred: $($_.Exception.Message)" -ForegroundColor Red Read-Host "Press Enter to exit" }