kms-website/static/scripts/setup-kms.ps1
Viktor Barzin efa1353e6b kms-website: activate against vlmcs.viktorbarzin.me, drop ODT-install + deep-legacy GVLKs
The page advertised kms.viktorbarzin.me:1688 as the KMS host, but that name
is the website (Traefik) — internally it resolves to 10.0.20.203 which has no
:1688 listener, so LAN clients failed with "KMS server cannot be reached".
Split the concern: siteHost (kms.viktorbarzin.me) serves the page + /scripts
downloads; kmsHost is now the dedicated A-only vlmcs.viktorbarzin.me endpoint
that resolves to the vlmcsd MetalLB IP (10.0.20.202) on the LAN (Technitium)
and to the public IP over the internet (Cloudflare -> pfSense WAN NAT :1688).

Moderate cleanup:
- remove the Office-install-via-ODT path from kms-bootstrap.ps1 (activation
  only now; manual ODT install docs stay on the page)
- collapse Windows 8.1/8/7/Vista + Server 2012/2008 GVLK tables into a legacy
  note (those keys still activate; just no longer tabled)
- drop the unused kmsHostLan param

Pairs with the infra /scripts Anubis carve-out that makes `iwr | iex` work.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-01 08:05:31 +00:00

67 lines
2.6 KiB
PowerShell

# setup-kms.ps1
#
# Minimal KMS-host wiring for an already-installed Volume License Windows.
# Runs `slmgr /skms <host>:<port>` + `slmgr /ato` and prints the licence status.
# Does NOT install Office. Does NOT change DNS suffix. Pin only.
#
# Usage:
# iwr -UseBasicParsing https://kms.viktorbarzin.me/scripts/setup-kms.ps1 | iex
#
# Or with a custom KMS host (e.g. self-hosted):
# $env:KMS_HOST = 'kms.example.com'; iwr ... | iex
#
# Source: https://kms.viktorbarzin.me/scripts/setup-kms.ps1
# Licence: MIT, no warranty, KMS activates Volume License SKUs only.
[CmdletBinding()]
param(
[string]$KmsHost = $(if ($env:KMS_HOST) { $env:KMS_HOST } else { 'vlmcs.viktorbarzin.me' }),
[int] $KmsPort = $(if ($env:KMS_PORT) { [int]$env:KMS_PORT } else { 1688 })
)
$ErrorActionPreference = 'Stop'
function Step($m) { Write-Host "==> $m" -ForegroundColor Cyan }
function OK($m) { Write-Host " OK: $m" -ForegroundColor Green }
function Bad($m) { Write-Host " !! $m" -ForegroundColor Red }
if (-not ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
Bad "Must run as Administrator. Right-click PowerShell -> 'Run as administrator', then retry."
return
}
Step "KMS host = $KmsHost`:$KmsPort"
$slmgr = "$env:WINDIR\System32\slmgr.vbs"
Step "slmgr /skms $KmsHost`:$KmsPort"
$out = & cscript //Nologo $slmgr /skms "$KmsHost`:$KmsPort" 2>&1
Write-Host $out
if ($LASTEXITCODE -ne 0) { Bad "slmgr /skms failed (exit $LASTEXITCODE)"; return }
OK "KMS host pinned"
Step "slmgr /ato (activate)"
$out = & cscript //Nologo $slmgr /ato 2>&1
Write-Host $out
if ($LASTEXITCODE -ne 0) {
Bad "slmgr /ato failed (exit $LASTEXITCODE)"
Write-Host ""
Write-Host "Most common cause: this Windows is not a Volume License edition."
Write-Host "KMS activates only VL SKUs (Pro, Enterprise, Education, LTSC, Server)."
Write-Host "Home / retail / OEM keys reject KMS responses. See https://kms.viktorbarzin.me/#faq"
return
}
OK "Activation request sent"
Step "slmgr /dlv (status)"
$out = & cscript //Nologo $slmgr /dlv 2>&1
Write-Host $out
if ($out -match 'License Status:\s*Licensed') {
Write-Host ""
Write-Host "==> SUCCESS: Windows is now licensed via KMS." -ForegroundColor Green
Write-Host " Licence renews automatically every 7 days; lasts 180 days per renewal."
} else {
Write-Host ""
Write-Host "==> Activation request sent but status is not 'Licensed' yet." -ForegroundColor Yellow
Write-Host " Re-run 'slmgr /dlv' in a minute, or check https://kms.viktorbarzin.me/#faq"
}