From f1440dfcf417e74c51c5a868e5d5d54c40ef4e6e Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Mon, 1 Jun 2026 10:18:24 +0000 Subject: [PATCH] kms-website: fix Office auto-key label filter ($_ shadowing in switch) Inside `switch ($label) {...}` the automatic $_ is the switch input (the label), not the Where-Object pipeline item, so the per-product filter always matched and KMS_AUTO=office would also install Project/Visio keys. Replace with explicit label/$_ comparisons. Co-Authored-By: Claude Opus 4.7 --- static/scripts/kms-bootstrap.ps1 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/static/scripts/kms-bootstrap.ps1 b/static/scripts/kms-bootstrap.ps1 index cb2a945..c647466 100644 --- a/static/scripts/kms-bootstrap.ps1 +++ b/static/scripts/kms-bootstrap.ps1 @@ -174,8 +174,12 @@ function Activate-Ospp([string]$label) { if ($st -match '---LICENSED---') { OK "$label already licensed - host set, skipping /act"; return } # Not licensed: install the matching GVLK for each installed VL product of # this family (Office = anything that isn't Project/Visio), fetched from the list. + # Match this family's installed VL products. NB: avoid `switch ($label)` here — + # inside a switch, $_ is the switch input (the label), not the pipeline item. $rels = Get-OfficeReleaseIds | Where-Object { - switch ($label) { 'Project' { $_ -match 'Project' } 'Visio' { $_ -match 'Visio' } default { $_ -notmatch 'Project|Visio' } } + ($label -eq 'Project' -and $_ -match 'Project') -or + ($label -eq 'Visio' -and $_ -match 'Visio') -or + ($label -eq 'Office' -and $_ -notmatch 'Project|Visio') } $keys = Get-Keys foreach ($rel in $rels) {