# Quick launcher for Windows network scan # Usage: .\run-scan.ps1 [-Network "192.168.1.0/24"] [-BatchSize 5] [-Fast] [-Verbose] # Or run without parameters for interactive menu param( [string]$Network = "", [int]$BatchSize = 0, [switch]$Verbose, [switch]$Fast ) function Show-ScanOptionsMenu { Write-Host "`nWOL Manager - Optiuni de Scanare" -ForegroundColor Yellow Write-Host "=================================" -ForegroundColor Yellow Write-Host "" # Scan mode selection Write-Host "Selecteaza modul de scanare:" -ForegroundColor White Write-Host " 1. Scan rapid (20 paralele, 500ms timeout)" -ForegroundColor Yellow Write-Host " 2. Scan standard (20 paralele, 1000ms timeout)" -ForegroundColor Cyan Write-Host " 3. Scan conservativ (10 paralele, 1500ms timeout)" -ForegroundColor Green Write-Host " 4. Configurare personalizata" -ForegroundColor Magenta Write-Host "" Write-Host " 0. Anuleaza" -ForegroundColor Red Write-Host "" do { $scanChoice = Read-Host "Selecteaza optiunea (0-4)" try { $scanChoiceNum = [int]$scanChoice } catch { Write-Host "Te rog introdu un numar valid!" -ForegroundColor Red continue } if ($scanChoiceNum -eq 0) { Write-Host "Scanare anulata." -ForegroundColor Yellow exit 0 } elseif ($scanChoiceNum -ge 1 -and $scanChoiceNum -le 4) { break } else { Write-Host "Optiune invalida! Selecteaza intre 0 si 4." -ForegroundColor Red } } while ($true) # Set scan parameters based on choice $scanParams = @{} switch ($scanChoiceNum) { 1 { $scanParams.BatchSize = 20 $scanParams.TimeoutMs = 500 $scanParams.Description = "Rapid" } 2 { $scanParams.BatchSize = 20 $scanParams.TimeoutMs = 1000 $scanParams.Description = "Standard" } 3 { $scanParams.BatchSize = 10 $scanParams.TimeoutMs = 1500 $scanParams.Description = "Conservativ" } 4 { Write-Host "`nConfigurare personalizata:" -ForegroundColor Magenta do { $customBatch = Read-Host "Numar de procese paralele (1-50, recomandat: 3-10)" try { $batchNum = [int]$customBatch if ($batchNum -ge 1 -and $batchNum -le 50) { $scanParams.BatchSize = $batchNum break } else { Write-Host "Valoare intre 1 si 50!" -ForegroundColor Red } } catch { Write-Host "Te rog introdu un numar valid!" -ForegroundColor Red } } while ($true) do { $customTimeout = Read-Host "Timeout per ping in ms (100-5000, recomandat: 500-2000)" try { $timeoutNum = [int]$customTimeout if ($timeoutNum -ge 100 -and $timeoutNum -le 5000) { $scanParams.TimeoutMs = $timeoutNum break } else { Write-Host "Valoare intre 100 si 5000!" -ForegroundColor Red } } catch { Write-Host "Te rog introdu un numar valid!" -ForegroundColor Red } } while ($true) $scanParams.Description = "Personalizat" } } # Ask for verbose mode Write-Host "" $verboseChoice = Read-Host "Afiseaza progres detaliat? (y/n, default: n)" $scanParams.Verbose = ($verboseChoice -eq "y" -or $verboseChoice -eq "Y") return $scanParams } $scriptPath = Join-Path $PSScriptRoot "windows-network-scan.ps1" $outputPath = Join-Path (Split-Path $PSScriptRoot -Parent) "data\network-scan-results.json" Write-Host "WOL Manager - Windows Network Scanner" -ForegroundColor Yellow Write-Host "=====================================" -ForegroundColor Yellow if (-not (Test-Path $scriptPath)) { Write-Error "Scanner script not found: $scriptPath" exit 1 } # Determine if we should show interactive menu $hasParams = $PSBoundParameters.Count -gt 0 -or $Network -or $BatchSize -gt 0 -or $Verbose -or $Fast if (-not $hasParams) { # Show interactive menu $menuParams = Show-ScanOptionsMenu $BatchSize = $menuParams.BatchSize $TimeoutMs = $menuParams.TimeoutMs $Verbose = $menuParams.Verbose $scanMode = $menuParams.Description Write-Host "`nMod selectat: $scanMode ($BatchSize paralele, $($TimeoutMs)ms timeout)" -ForegroundColor Green } # Set up scan parameters $params = @{ OutputPath = $outputPath } # Handle command line parameters vs interactive menu if ($hasParams) { # Command line mode if ($Fast) { $params.TimeoutMs = 200 $params.BatchSize = 20 Write-Host "Fast scan mode enabled (200ms timeout, 20 parallel)" -ForegroundColor Yellow } else { $params.TimeoutMs = 1000 $params.BatchSize = if ($BatchSize -gt 0) { $BatchSize } else { 5 } Write-Host "Standard scan mode ($($params.BatchSize) parallel, $($params.TimeoutMs)ms timeout)" -ForegroundColor Green } if ($Verbose) { $params.Verbose = $true } } else { # Interactive menu mode - parameters already set above $params.BatchSize = $BatchSize $params.TimeoutMs = $TimeoutMs if ($Verbose) { $params.Verbose = $true } } if ($Network) { $params.Network = $Network Write-Host "Scanning network: $Network" -ForegroundColor Cyan } else { Write-Host "Network will be selected interactively" -ForegroundColor Cyan } try { & $scriptPath @params if ($LASTEXITCODE -eq 0) { Write-Host "`nScan completed successfully!" -ForegroundColor Green Write-Host "Results saved to: $outputPath" -ForegroundColor Green } } catch { Write-Error "Failed to run network scan: $_" exit 1 }