# Windows 11 LTSC IoT VM Setup Script # Run this INSIDE the Windows VM after installation # Run as Administrator in PowerShell #Requires -RunAsAdministrator # ============================================ # CONFIGURATION # ============================================ $VM_IP = "192.168.5.211" # Static IP for Windows VM $MAIN_DEV_IP = "192.168.5.210" # IP of your Ubuntu Dev VM # Colors for output function Write-Info { param($Message) Write-Host "[INFO] $Message" -ForegroundColor Cyan } function Write-Success { param($Message) Write-Host "[SUCCESS] $Message" -ForegroundColor Green } function Write-Warning { param($Message) Write-Host "[WARNING] $Message" -ForegroundColor Yellow } function Write-Error { param($Message) Write-Host "[ERROR] $Message" -ForegroundColor Red } Write-Info "Starting Windows LTSC IoT VM Setup..." # ============================================ # ENABLE SSH SERVER # ============================================ Write-Info "Enabling OpenSSH Server..." # Install OpenSSH Server Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0 # Start and enable service Start-Service sshd Set-Service -Name sshd -StartupType 'Automatic' # Configure firewall if (!(Get-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -ErrorAction SilentlyContinue)) { New-NetFirewallRule -Name "OpenSSH-Server-In-TCP" -DisplayName "OpenSSH Server (sshd)" ` -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 22 } Write-Success "SSH Server enabled" # ============================================ # ENABLE RDP # ============================================ Write-Info "Enabling Remote Desktop..." Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' ` -Name "fDenyTSConnections" -Value 0 Enable-NetFirewallRule -DisplayGroup "Remote Desktop" # Enhanced RDP security Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' ` -Name "UserAuthentication" -Value 1 Write-Success "RDP enabled" # ============================================ # CREATE TEST USER # ============================================ Write-Info "Creating test user account..." $TestUser = "testuser" $TestPassword = ConvertTo-SecureString "DevMatrix2024!" -AsPlainText -Force # Check if user exists if (!(Get-LocalUser -Name $TestUser -ErrorAction SilentlyContinue)) { New-LocalUser -Name $TestUser -Password $TestPassword ` -FullName "Test User" -Description "DevMatrix Test Account" Add-LocalGroupMember -Group "Administrators" -Member $TestUser Add-LocalGroupMember -Group "Remote Desktop Users" -Member $TestUser Write-Success "Test user '$TestUser' created" } else { Write-Warning "Test user already exists" } # ============================================ # INSTALL CHOCOLATEY # ============================================ Write-Info "Installing Chocolatey package manager..." if (!(Get-Command choco -ErrorAction SilentlyContinue)) { Set-ExecutionPolicy Bypass -Scope Process -Force [System.Net.ServicePointManager]::SecurityProtocol = ` [System.Net.ServicePointManager]::SecurityProtocol -bor 3072 Invoke-Expression ((New-Object System.Net.WebClient). ` DownloadString('https://community.chocolatey.org/install.ps1')) # Refresh environment $env:Path = [System.Environment]::GetEnvironmentVariable("Path","Machine") + ";" + ` [System.Environment]::GetEnvironmentVariable("Path","User") Write-Success "Chocolatey installed" } else { Write-Warning "Chocolatey already installed" } # ============================================ # INSTALL DEVELOPMENT TOOLS # ============================================ Write-Info "Installing development tools..." $packages = @( "git" "python" "nodejs" "dotnet-sdk" "vscode" "firefox" "googlechrome" "7zip" "powertoys" "sysinternals" "processhacker" ) foreach ($pkg in $packages) { Write-Info "Installing $pkg..." choco install $pkg -y --no-progress } Write-Success "Development tools installed" # ============================================ # INSTALL PLAYWRIGHT # ============================================ Write-Info "Installing Playwright for UI testing..." npm install -g @playwright/test npx playwright install chromium firefox webkit npx playwright install-deps Write-Success "Playwright installed" # ============================================ # CREATE TEST DIRECTORIES # ============================================ Write-Info "Creating test directories..." $directories = @( "C:\Apps", "C:\Tests", "C:\Projects", "C:\Results", "C:\Scripts" ) foreach ($dir in $directories) { if (!(Test-Path $dir)) { New-Item -ItemType Directory -Force -Path $dir } } Write-Success "Test directories created" # ============================================ # CREATE TEST RUNNER SCRIPTS # ============================================ Write-Info "Creating test automation scripts..." # Simple test runner $TestRunner = @' @echo off echo ======================================== echo DevMatrix Windows Test Runner echo Started: %date% %time% echo ======================================== echo. if "%~1"=="" ( echo Usage: run_tests.bat ^ exit /b 1 ) set TEST_DIR=%~1 echo Running tests from: %TEST_DIR% echo. cd /d %TEST_DIR% if errorlevel 1 ( echo ERROR: Cannot access directory %TEST_DIR% exit /b 1 ) echo Test Start > C:\Results\test_session.log echo %date% %time% >> C:\Results\test_session.log echo. >> C:\Results\test_session.log REM Run Playwright tests if playwright.config.js exists if exist "playwright.config.js" ( echo Running Playwright tests... npx playwright test --reporter=html --output=C:\Results set TEST_EXIT=%errorlevel% ) else ( echo No Playwright config found. Looking for other tests... dir /s /b *.test.js *.spec.js > nul 2>&1 if !errorlevel!==0 ( echo Found JavaScript tests. Running with Node... for /r %%i in (*.test.js *.spec.js) do ( echo Running: %%i node "%%i" >> C:\Results\test_session.log 2>&1 ) ) ) echo. >> C:\Results\test_session.log echo Test End: %date% %time% >> C:\Results\test_session.log echo. echo ======================================== echo Tests complete. Results in C:\Results\ echo ======================================== exit /b %TEST_EXIT% '@ $TestRunner | Out-File -FilePath "C:\Scripts\run_tests.bat" -Encoding ASCII # App installer script $AppInstaller = @' @echo off echo DevMatrix App Installer echo ======================= if "%~1"=="" ( echo Usage: install_app.bat ^ exit /b 1 ) set APP_PATH=%~1 set APP_NAME=%~n1 echo Installing: %APP_NAME% echo From: %APP_PATH% REM Create app directory if not exist "C:\Apps\%APP_NAME%" mkdir "C:\Apps\%APP_NAME%" REM Copy files xcopy /E /I /Y "%APP_PATH%\*" "C:\Apps\%APP_NAME%\" echo. echo Installation complete: C:\Apps\%APP_NAME%\ echo. echo To run: C:\Apps\%APP_NAME%\%APP_NAME%.exe '@ $AppInstaller | Out-File -FilePath "C:\Scripts\install_app.bat" -Encoding ASCII Write-Success "Automation scripts created" # ============================================ # CONFIGURE WINRM (FOR AUTOMATION) # ============================================ Write-Info "Configuring WinRM for remote automation..." # Enable WinRM Enable-PSRemoting -Force -SkipNetworkProfileCheck # Configure WinRM to allow unencrypted (local network only) Set-Item WSMan:\localhost\Service\AllowUnencrypted -Value $true Set-Item WSMan:\localhost\Service\Auth\Basic -Value $true # Configure firewall Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP" -RemoteAddress LocalSubnet Set-NetFirewallRule -Name "WINRM-HTTP-In-TCP-PUBLIC" -RemoteAddress LocalSubnet Write-Success "WinRM configured" # ============================================ # INSTALL WSL2 (OPTIONAL) # ============================================ Write-Info "Installing WSL2 for Linux compatibility..." # Enable WSL wsl --install --no-distribution Write-Success "WSL2 installed (reboot required to complete)" # ============================================ # PERFORMANCE OPTIMIZATIONS # ============================================ Write-Info "Applying performance optimizations..." # Disable unnecessary visual effects $regPath = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\VisualEffects" Set-ItemProperty -Path $regPath -Name "VisualFXSetting" -Value 2 # Set high performance power plan powercfg /setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c # Disable Windows Search indexing for test directories Add-Content -Path "C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1" -Value @" # DevMatrix Performance Settings `$env:DOTNET_CLI_TELEMETRY_OPTOUT = 1 `$env:POWERSHELL_TELEMETRY_OPTOUT = 1 "@ Write-Success "Performance optimizations applied" # ============================================ # CREATE FIREWALL RULES FOR DEVMATRIX # ============================================ Write-Info "Creating DevMatrix firewall rules..." # Allow traffic from main dev VM New-NetFirewallRule -DisplayName "DevMatrix-DevVM" ` -Direction Inbound -Action Allow ` -RemoteAddress $MAIN_DEV_IP ` -Profile Private # Allow file sharing Set-NetFirewallRule -DisplayGroup "File and Printer Sharing" -Enabled True -Profile Private Write-Success "Firewall rules created" # ============================================ # SUMMARY # ============================================ Write-Host "" Write-Host "╔════════════════════════════════════════════════════════════╗" -ForegroundColor Green Write-Host "║ WINDOWS VM SETUP COMPLETE ║" -ForegroundColor Green Write-Host "╠════════════════════════════════════════════════════════════╣" -ForegroundColor Green Write-Host "║ ║" -ForegroundColor Green Write-Host "║ ✅ SSH Server: Enabled on port 22 ║" -ForegroundColor Green Write-Host "║ ✅ RDP: Enabled ║" -ForegroundColor Green Write-Host "║ ✅ Test User: testuser / DevMatrix2024! ║" -ForegroundColor Green Write-Host "║ ✅ Dev Tools: Git, Python, Node, .NET, VS Code ║" -ForegroundColor Green Write-Host "║ ✅ Testing: Playwright installed ║" -ForegroundColor Green Write-Host "║ ✅ Directories: C:\Apps, C:\Tests, C:\Results ║" -ForegroundColor Green Write-Host "║ ║" -ForegroundColor Green Write-Host "╠════════════════════════════════════════════════════════════╣" -ForegroundColor Green Write-Host "║ Connect from Dev VM: ║" -ForegroundColor Green Write-Host "║ ssh testuser@$VM_IP ║" -ForegroundColor Green Write-Host "║ scp -r ./app testuser@${VM_IP}:/C:/Apps/ ║" -ForegroundColor Green Write-Host "╚════════════════════════════════════════════════════════════╝" -ForegroundColor Green Write-Host "" Write-Warning "REBOOT REQUIRED for WSL2 to complete installation" Write-Host "" Write-Info "After reboot, this VM is ready for automated testing!"