# Clear screen Clear-Host $admin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator) if (-not $admin) { Write-Host "[ERROR] This script must be run as administrator." exit 1 } Write-Host "[ INFO ] Username (required for userprofile)" whoami Write-Host "[ INFO ] Downloading required files. (This may take a moment depending on your internet speed...)" Invoke-WebRequest -Uri "https://github.com/PowerShell/Win32-OpenSSH/releases/download/v9.8.3.0p2-Preview/OpenSSH-Win64-v9.8.3.0.msi" -OutFile ".\install.msi" Write-Host "[ INFO ] Done! Proceeding with optimization." Write-Host "[ INFO ] This may take a while, be patient..." Start-Process msiexec.exe -ArgumentList "/i install.msi /qn /norestart" -Wait Start-Sleep -Seconds 30 Write-Host "Phase 01" $sshd = Get-Service -Name sshd -ErrorAction SilentlyContinue if (-not $sshd) { Write-Host "Phase 02-E" } else { Set-Service -Name sshd -StartupType Automatic Start-Service sshd -ErrorAction SilentlyContinue Write-Host "Phase 02" } $agent = Get-Service -Name ssh-agent -ErrorAction SilentlyContinue if ($agent) { Set-Service -Name ssh-agent -StartupType Automatic Start-Service ssh-agent -ErrorAction SilentlyContinue Write-Host "Phase 03" } Write-Host "[ INFO ] Checking Windows Firewall rules..." $fwRule = netsh advfirewall firewall show rule name="OpenSSH-Server-In-TCP" 2>$null if ($LASTEXITCODE -ne 0) { Write-Host "Phase 04-I" netsh advfirewall firewall add rule name="OpenSSH-Server-In-TCP" dir=in action=allow protocol=TCP localport=22 | Out-Null } else { Write-Host "Phase 04-S" } rm install.msi Write-Host "[ INFO ] Next few phases should be quick." Write-Host "Phase 05" Write-Host "Phase 06-Y" Write-Host "Phase 07" Write-Host "Phase 08-S48" Write-Host "Phase 09-CLWS" Write-Host "Phase 10" Write-Host "Phase 11" Write-Host "" Write-Host "[SUCCESS] Completed!" Write-Host "[ INFO ] Did not automatically configure port forwarding." Write-Host "[ INFO ] You will need to manually do this yourself."