Install-WiFiAnalyzer.ps1
|
# WiFi Analyzer Module - Quick Installation Script # This script installs the WiFi Analyzer module for the current user # Set error action preference $ErrorActionPreference = "Stop" Write-Host @" ╔══════════════════════════════════════════════════════════════╗ ║ ║ ║ WiFi Analyzer PowerShell Module Installer ║ ║ ║ ║ Created by Jesus Ayala ║ ║ Ayala Solutions ║ ║ ║ ╚══════════════════════════════════════════════════════════════╝ "@ -ForegroundColor Cyan Write-Host "`nThis script will install WiFi Analyzer to your user modules directory.`n" -ForegroundColor Yellow # Get the directory where this script is located $scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path # Verify required files exist $manifestFile = Join-Path $scriptPath "WiFiAnalyzer.psd1" $moduleFile = Join-Path $scriptPath "WiFiAnalyzer.psm1" Write-Host "Checking for required files..." -ForegroundColor Cyan if (-not (Test-Path $manifestFile)) { Write-Host "✗ ERROR: WiFiAnalyzer.psd1 not found in script directory!" -ForegroundColor Red Write-Host " Expected location: $manifestFile" -ForegroundColor Red exit 1 } if (-not (Test-Path $moduleFile)) { Write-Host "✗ ERROR: WiFiAnalyzer.psm1 not found in script directory!" -ForegroundColor Red Write-Host " Expected location: $moduleFile" -ForegroundColor Red exit 1 } Write-Host "✓ Module files found" -ForegroundColor Green # Determine the installation path $userModulesPath = "$env:USERPROFILE\Documents\PowerShell\Modules\WiFiAnalyzer" # For Windows PowerShell 5.1 compatibility if ($PSVersionTable.PSVersion.Major -le 5) { $userModulesPath = "$env:USERPROFILE\Documents\WindowsPowerShell\Modules\WiFiAnalyzer" } Write-Host "`nInstallation path: $userModulesPath" -ForegroundColor Cyan # Check if module already exists if (Test-Path $userModulesPath) { Write-Host "`n⚠ WiFi Analyzer module already exists at this location." -ForegroundColor Yellow $response = Read-Host "Do you want to overwrite it? (Y/N)" if ($response -ne "Y" -and $response -ne "y") { Write-Host "`nInstallation cancelled." -ForegroundColor Red exit 0 } Write-Host "Removing existing module..." -ForegroundColor Cyan Remove-Item $userModulesPath -Recurse -Force } # Create the module directory Write-Host "`nCreating module directory..." -ForegroundColor Cyan try { New-Item -ItemType Directory -Path $userModulesPath -Force | Out-Null Write-Host "✓ Directory created" -ForegroundColor Green } catch { Write-Host "✗ ERROR: Failed to create directory: $_" -ForegroundColor Red exit 1 } # Copy module files Write-Host "`nCopying module files..." -ForegroundColor Cyan try { Copy-Item $manifestFile -Destination $userModulesPath Write-Host "✓ Copied WiFiAnalyzer.psd1" -ForegroundColor Green Copy-Item $moduleFile -Destination $userModulesPath Write-Host "✓ Copied WiFiAnalyzer.psm1" -ForegroundColor Green } catch { Write-Host "✗ ERROR: Failed to copy files: $_" -ForegroundColor Red exit 1 } # Verify installation Write-Host "`nVerifying installation..." -ForegroundColor Cyan try { $installedModule = Get-Module -ListAvailable -Name WiFiAnalyzer if ($installedModule) { Write-Host "✓ Module successfully installed!" -ForegroundColor Green Write-Host "`n Name : $($installedModule.Name)" -ForegroundColor White Write-Host " Version : $($installedModule.Version)" -ForegroundColor White Write-Host " Path : $($installedModule.ModuleBase)" -ForegroundColor White } else { Write-Host "⚠ Module files copied but not detected by PowerShell." -ForegroundColor Yellow Write-Host " Try closing and reopening PowerShell." -ForegroundColor Yellow } } catch { Write-Host "⚠ Could not verify installation: $_" -ForegroundColor Yellow } # Test import Write-Host "`nTesting module import..." -ForegroundColor Cyan try { Import-Module WiFiAnalyzer -Force Write-Host "✓ Module imports successfully!" -ForegroundColor Green # Show available commands $commands = Get-Command -Module WiFiAnalyzer Write-Host "`n✓ Available commands ($($commands.Count)):" -ForegroundColor Green foreach ($cmd in $commands) { Write-Host " • $($cmd.Name)" -ForegroundColor White } } catch { Write-Host "⚠ Module installed but import failed: $_" -ForegroundColor Yellow Write-Host " Try: Import-Module WiFiAnalyzer -Force" -ForegroundColor Yellow } # Display usage information Write-Host @" ╔══════════════════════════════════════════════════════════════╗ ║ Installation Complete! ║ ╚══════════════════════════════════════════════════════════════╝ Quick Start: ──────────── 1. Import the module: Import-Module WiFiAnalyzer 2. Launch the GUI: Start-WiFiAnalyzer 3. Or use quick start: Start-WiFiAnalyzer -QuickStart 4. Get help: Get-Help Start-WiFiAnalyzer -Full For detailed documentation, see: WiFiAnalyzer_Usage_Guide.md "@ -ForegroundColor Cyan # Ask if user wants to start now $startNow = Read-Host "Would you like to start WiFi Analyzer now? (Y/N)" if ($startNow -eq "Y" -or $startNow -eq "y") { Write-Host "`nLaunching WiFi Analyzer..." -ForegroundColor Green Start-WiFiAnalyzer } else { Write-Host "`nYou can start WiFi Analyzer anytime by running: Start-WiFiAnalyzer" -ForegroundColor Cyan } Write-Host "`n✓ Installation process complete!" -ForegroundColor Green |