Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

Detect missing admin elevation when Vagrant distros are requested

Juan Denis4657483f102a
diff --git a/scripts/test/README.md b/scripts/test/README.md
index 6a3b84e2..c3eb1a3e 100644
--- a/scripts/test/README.md
+++ b/scripts/test/README.md
@@ -18,6 +18,10 @@ installer actually works on multiple distros" use case.
```powershell
winget install Hashicorp.Vagrant
```
+ **Note:** Vagrant + Hyper-V requires running the script from an
+ **elevated** PowerShell (right-click → Run as Administrator). If you
+ run as a normal user, the script will tell you and exit cleanly.
+ Multipass-only runs (Ubuntu) don't need admin.
3. **Python 3** on PATH (for the HTML report generator; tests run inside the VMs).
4. **Hyper-V** enabled (both Multipass and Vagrant use it on Windows).
diff --git a/scripts/test/full-stack-test.ps1 b/scripts/test/full-stack-test.ps1
index e7be51f7..412e4960 100644
--- a/scripts/test/full-stack-test.ps1
+++ b/scripts/test/full-stack-test.ps1
@@ -103,6 +103,24 @@ if (-not $Distros -or $Distros.Count -eq 0) {
exit 2
}
+# Vagrant + Hyper-V requires the process itself to run elevated. Being in
+# the Hyper-V Administrators group is necessary but not sufficient.
+$needsAdmin = $Distros | Where-Object { $DistroMap[$_].backend -eq 'vagrant' }
+if ($needsAdmin) {
+ $isAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole(
+ [Security.Principal.WindowsBuiltInRole]::Administrator)
+ if (-not $isAdmin) {
+ Write-Host "" -ForegroundColor Red
+ Write-Host "Vagrant + Hyper-V requires an elevated PowerShell." -ForegroundColor Red
+ Write-Host "Requested distros that need it: $($needsAdmin -join ', ')" -ForegroundColor Red
+ Write-Host "" -ForegroundColor Red
+ Write-Host "Either:" -ForegroundColor Yellow
+ Write-Host " 1. Right-click PowerShell -> Run as Administrator, then re-run this script." -ForegroundColor Yellow
+ Write-Host " 2. Or run with -Only ubuntu22,ubuntu24 to skip Vagrant distros." -ForegroundColor Yellow
+ exit 2
+ }
+}
+
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " ServerKit E2E Test - run $RunId" -ForegroundColor Cyan
if ($MpExe) { Write-Host " Multipass: $MpExe" -ForegroundColor Cyan }