Skip to content

Commit

Permalink
Update exclusion of registry to include Server 2012R2 (#253)
Browse files Browse the repository at this point in the history
* Switch to registry based verification

Except for Server 2008 which doesn't use registry to store status, this will resolve issues with attempting to activate windows when English is not the system display language.

* Consolidate to a single guaranteed return

More optimal given a single guaranteed return

* Update catch behavior for failed license lookup

Log the message rather than set $active which is already false

* Update note on Server version

Reflect previous change
  • Loading branch information
jjerger authored Aug 28, 2024
1 parent aab2d0f commit e36e3f2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions sysprep/activate_instance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ function Verify-ActivationStatus {
[String]$status = $null

# Server 2008 doesn't store activation status in registry; check slmgr
if([Environment]::OSVersion.Version.Major -eq 6 -and [Environment]::OSVersion.Version.Minor -le 1)
if([Environment]::OSVersion.Version.Major -eq 6 -and [Environment]::OSVersion.Version.Minor -le 3)
{
try {
$slmgr_status = & cscript //E:VBScript //nologo $env:windir\system32\slmgr.vbs /dli
Expand All @@ -281,7 +281,7 @@ function Verify-ActivationStatus {
$active = $true
}
}
# All server versions newer than 2008
# All server versions newer than 2012R2
else {
try {
$activation_status = (Get-ItemProperty -Path "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform\Activation" -Name ProductActivationResult).ProductActivationResult
Expand Down

0 comments on commit e36e3f2

Please sign in to comment.