2024-07-13 04:46:38 +05:30
@ echo off
2026-01-27 17:12:28 +04:00
: :============================================================================
: :
2024-07-13 04:46:38 +05:30
: : Check-Activation-Status
: : Written by @abbodi1406
2026-01-27 17:12:28 +04:00
: :
: :============================================================================
2024-07-13 04:46:38 +05:30
2024-08-18 05:08:35 +05:30
: : Set Environment variables, it helps if they are misconfigured in the system
setlocal EnableExtensions
setlocal DisableDelayedExpansion
set "PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC"
set "SysPath= %SystemRoot% \System32"
2024-07-13 04:46:38 +05:30
set "Path= %SystemRoot% \System32; %SystemRoot% ; %SystemRoot% \System32\Wbem; %SystemRoot% \System32\WindowsPowerShell\v1.0\"
if exist " %SystemRoot% \Sysnative\reg.exe" (
2024-08-18 05:08:35 +05:30
set "SysPath= %SystemRoot% \Sysnative"
2024-07-13 04:46:38 +05:30
set "Path= %SystemRoot% \Sysnative; %SystemRoot% ; %SystemRoot% \Sysnative\Wbem; %SystemRoot% \Sysnative\WindowsPowerShell\v1.0\; %Path% "
)
2024-08-18 05:08:35 +05:30
set "ComSpec= %SysPath% \cmd.exe"
set "PSModulePath= %ProgramFiles% \WindowsPowerShell\Modules; %SysPath% \WindowsPowerShell\v1.0\Modules"
2025-04-20 19:35:53 +05:30
set "ps= %SysPath% \WindowsPowerShell\v1.0\powershell.exe"
set "_psc= %ps% -nop -c"
2024-07-13 04:46:38 +05:30
set "_err===== ERROR ===="
set _pwsh = 1
2025-04-20 19:35:53 +05:30
if not exist %ps% set _pwsh = 0
2024-07-13 04:46:38 +05:30
cmd /c " %_psc% " $ExecutionContext.SessionState.LanguageMode"" | find /i "FullLanguage" 1 > nul || ( set _pwsh = 0)
if %_pwsh% equ 0 (
echo %_err%
cmd /c " %_psc% " $ExecutionContext.SessionState.LanguageMode""
echo Windows PowerShell is not working correctly.
echo It is required for this script to work.
goto : E_Exit
)
set "_batf= %~f0 "
set "_batp= %_batf:'=''% "
setlocal EnableDelayedExpansion
2026-05-07 14:01:10 +00:00
%_psc% "$f=[IO.File]::ReadAllText('!_batp!') -split ':sppmgr\:.*';. ([scriptblock]::Create($f[1]))"
2024-07-13 04:46:38 +05:30
: E_Exit
echo .
2024-08-18 05:08:35 +05:30
echo Press 0 key to exit.
choice /c 0 /n
2024-07-13 04:46:38 +05:30
exit /b
: sppmgr :
2025-01-30 02:25:04 +05:30
param (
[Parameter()]
[switch]
$All,
[Parameter()]
[switch]
$Dlv,
[Parameter()]
[switch]
$IID,
[Parameter()]
[switch]
$Pass
)
function CONOUT($strObj)
{
Out-Host -Input $strObj
}
2024-07-13 04:46:38 +05:30
function ExitScript($ExitCode = 0)
{
Exit $ExitCode
}
if (-Not $PSVersionTable) {
2025-01-30 02:25:04 +05:30
"==== ERROR ====`r`n"
"Windows PowerShell 1.0 is not supported by this script."
2024-07-13 04:46:38 +05:30
ExitScript 1
}
if ($ExecutionContext.SessionState.LanguageMode.value__ -NE 0) {
2025-01-30 02:25:04 +05:30
"==== ERROR ====`r`n"
"Windows PowerShell is not running in Full Language Mode."
2024-07-13 04:46:38 +05:30
ExitScript 1
}
$winbuild = 1
try {
$winbuild = [System.Diagnostics.FileVersionInfo]::GetVersionInfo("$env:SystemRoot\System32\kernel32.dll" ).FileBuildPart
} catch {
2025-01-30 02:25:04 +05:30
$winbuild = [int]([wmi]'Win32_OperatingSystem=@').BuildNumber
2024-07-13 04:46:38 +05:30
}
if ($winbuild -EQ 1) {
2025-01-30 02:25:04 +05:30
"==== ERROR ====`r`n"
"Could not detect Windows build."
2024-07-13 04:46:38 +05:30
ExitScript 1
}
if ($winbuild -LT 2600) {
2025-01-30 02:25:04 +05:30
"==== ERROR ====`r`n"
"This build of Windows is not supported by this script."
ExitScript 1
}
if ($All.IsPresent)
{
$isAll = {CONOUT "`r" }
$noAll = {$null}
}
else
{
$isAll = {$null}
$noAll = {CONOUT "`r" }
}
$Dlv = $Dlv.IsPresent
$IID = $IID.IsPresent -Or $Dlv.IsPresent
2024-07-13 04:46:38 +05:30
$NT6 = $winbuild -GE 6000
$NT7 = $winbuild -GE 7600
2025-04-16 03:47:15 +05:30
$NT8 = $winbuild -GE 9200
2024-07-13 04:46:38 +05:30
$NT9 = $winbuild -GE 9600
$Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
$line2 = "============================================================"
$line3 = "____________________________________________________________"
function echoWindows
{
2025-01-30 02:25:04 +05:30
CONOUT "$line2"
CONOUT "=== Windows Status ==="
CONOUT "$line2"
& $noAll
2024-07-13 04:46:38 +05:30
}
function echoOffice
{
if ($doMSG -EQ 0) {
return
}
2025-01-30 02:25:04 +05:30
& $isAll
CONOUT "$line2"
CONOUT "=== Office Status ==="
CONOUT "$line2"
& $noAll
2024-07-13 04:46:38 +05:30
$script:doMSG = 0
}
function strGetRegistry($strKey, $strName)
{
2025-01-30 02:25:04 +05:30
try {
return [Microsoft.Win32.Registry]::GetValue($strKey, $strName, $null)
} catch {
return $null
}
2024-07-13 04:46:38 +05:30
}
function CheckOhook
{
$ohook = 0
$paths = "${env:ProgramFiles}" , "${env:ProgramW6432}" , "${env:ProgramFiles(x86)}"
15, 16 | foreach `
{
$A = $_; $paths | foreach `
{
if (Test-Path "$($_)$('\Microsoft Office\Office')$($A)$('\sppc*dll')") {$ohook = 1}
}
}
"System" , "SystemX86" | foreach `
{
$A = $_; "Office 15" , "Office" | foreach `
{
$B = $_; $paths | foreach `
{
if (Test-Path "$($_)$('\Microsoft ')$($B)$('\root\vfs\')$($A)$('\sppc*dll')") {$ohook = 1}
}
}
}
if ($ohook -EQ 0) {
return
}
2025-01-30 02:25:04 +05:30
& $isAll
CONOUT "$line2"
CONOUT "=== Office Ohook Status ==="
CONOUT "$line2"
$host.UI.WriteLine('Yellow', 'Black', "`r`nOhook for permanent Office activation is installed.`r`nYou can ignore the below mentioned Office activation status." )
& $noAll
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
#region SSSS
function BoolToWStr($bVal) {
( "TRUE" , "FALSE" ) [!$bVal]
}
function InitializePInvoke($LaDll, $bOffice) {
2025-04-29 22:40:56 +05:30
$LaName = [IO.Path]::GetFileNameWithoutExtension($LaDll)
$SLApp = $NT7 -Or $bOffice -Or ($LaName -EQ 'sppc' -And [Diagnostics.FileVersionInfo]::GetVersionInfo("$SysPath\sppc.dll" ).FilePrivatePart -GE 16501)
$Win32 = $null
2025-04-16 03:47:15 +05:30
$Marshal = [System.Runtime.InteropServices.Marshal]
2025-04-29 22:40:56 +05:30
$Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly(($LaName+"_Assembly" ), 'Run').DefineDynamicModule(($LaName+"_Module" ), $False)
$Class = $Module.DefineType(($LaName+"_Methods" ), 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0)
2025-04-16 03:47:15 +05:30
$Class.DefinePInvokeMethod('SLClose', $LaDll, 22, 1, [Int32], @([IntPtr]), 1, 3).SetImplementationFlags(128)
$Class.DefinePInvokeMethod('SLOpen', $LaDll, 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
$Class.DefinePInvokeMethod('SLGenerateOfflineInstallationId', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
$Class.DefinePInvokeMethod('SLGetSLIDList', $LaDll, 22, 1, [Int32], @([IntPtr], [UInt32], [Guid].MakeByRefType(), [UInt32], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
$Class.DefinePInvokeMethod('SLGetLicensingStatusInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [Guid].MakeByRefType(), [IntPtr], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
$Class.DefinePInvokeMethod('SLGetPKeyInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
$Class.DefinePInvokeMethod('SLGetProductSkuInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
$Class.DefinePInvokeMethod('SLGetServiceInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
if ($SLApp) {
$Class.DefinePInvokeMethod('SLGetApplicationInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
}
if ($bOffice) {
$Win32 = $Class.CreateType()
return
}
if ($NT6) {
$Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
$Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128)
$Class.DefinePInvokeMethod('SLIsGenuineLocal', 'slwga.dll', 22, 1, [Int32], @([Guid].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr]), 1, 3).SetImplementationFlags(128)
}
if ($NT7) {
$Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig')
}
if ($DllSubscription) {
$Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
$Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0)
[void]$Struct.DefineField('dwEnabled', [UInt32], 'Public')
[void]$Struct.DefineField('dwSku', [UInt32], 6)
[void]$Struct.DefineField('dwState', [UInt32], 6)
$SubStatus = $Struct.CreateType()
}
$Win32 = $Class.CreateType()
}
function SlGetInfoIID($SkuId)
2024-07-13 04:46:38 +05:30
{
2025-04-16 03:47:15 +05:30
$bData = 0
if ($Win32::SLGenerateOfflineInstallationId(
$hSLC,
[ref][Guid]$SkuId,
[ref]$bData
))
{
return $null
}
2025-04-29 22:40:56 +05:30
else
{
return $Marshal::PtrToStringUni($bData)
}
2024-07-13 04:46:38 +05:30
}
2025-04-29 22:40:56 +05:30
function SlReturnData($hrRet, $tData, $cData, $bData) {
if ($hrRet -NE 0 -Or $cData -EQ 0)
2025-04-16 03:47:15 +05:30
{
return $null
}
if ($tData -EQ 1)
{
2025-04-29 22:40:56 +05:30
return $Marshal::PtrToStringUni($bData)
2025-04-16 03:47:15 +05:30
}
elseif ($tData -EQ 4)
{
2025-04-29 22:40:56 +05:30
return $Marshal::ReadInt32($bData)
2025-04-16 03:47:15 +05:30
}
elseif ($tData -EQ 3 -And $cData -EQ 8)
{
2025-04-29 22:40:56 +05:30
return $Marshal::ReadInt64($bData)
2025-04-16 03:47:15 +05:30
}
else
{
2025-04-29 22:40:56 +05:30
return $null
2025-04-16 03:47:15 +05:30
}
}
2025-04-29 22:40:56 +05:30
function SlGetInfoPKey($PkeyId, $Value)
2025-04-16 03:47:15 +05:30
{
$tData = 0
$cData = 0
$bData = 0
2025-04-29 22:40:56 +05:30
$hrRet = $Win32::SLGetPKeyInformation(
2025-04-16 03:47:15 +05:30
$hSLC,
2025-04-29 22:40:56 +05:30
[ref][Guid]$PkeyId,
2025-04-16 03:47:15 +05:30
$Value,
[ref]$tData,
[ref]$cData,
[ref]$bData
)
2025-04-29 22:40:56 +05:30
return SlReturnData $hrRet $tData $cData $bData
}
2025-04-16 03:47:15 +05:30
2025-04-29 22:40:56 +05:30
function SlGetInfoSku($SkuId, $Value)
{
$tData = 0
$cData = 0
$bData = 0
2025-04-16 03:47:15 +05:30
2025-04-29 22:40:56 +05:30
$hrRet = $Win32::SLGetProductSkuInformation(
$hSLC,
[ref][Guid]$SkuId,
$Value,
[ref]$tData,
[ref]$cData,
[ref]$bData
)
return SlReturnData $hrRet $tData $cData $bData
2025-04-16 03:47:15 +05:30
}
function SlGetInfoApp($AppId, $Value)
{
$tData = 0
$cData = 0
$bData = 0
2025-04-29 22:40:56 +05:30
$hrRet = $Win32::SLGetApplicationInformation(
2025-04-16 03:47:15 +05:30
$hSLC,
[ref][Guid]$AppId,
$Value,
[ref]$tData,
[ref]$cData,
[ref]$bData
)
2025-04-29 22:40:56 +05:30
return SlReturnData $hrRet $tData $cData $bData
2025-04-16 03:47:15 +05:30
}
2025-04-29 22:40:56 +05:30
function SlGetInfoService($Value)
2025-04-16 03:47:15 +05:30
{
2025-04-29 22:40:56 +05:30
$tData = 0
2025-04-16 03:47:15 +05:30
$cData = 0
$bData = 0
2025-04-29 22:40:56 +05:30
$hrRet = $Win32::SLGetServiceInformation(
2025-04-16 03:47:15 +05:30
$hSLC,
$Value,
2025-04-29 22:40:56 +05:30
[ref]$tData,
2025-04-16 03:47:15 +05:30
[ref]$cData,
[ref]$bData
)
2025-04-29 22:40:56 +05:30
return SlReturnData $hrRet $tData $cData $bData
}
function SlGetInfoSvcApp($strApp, $Value)
{
if ($SLApp)
2025-04-16 03:47:15 +05:30
{
2025-04-29 22:40:56 +05:30
return SlGetInfoApp $strApp $Value
}
else
{
return SlGetInfoService $Value
2025-04-16 03:47:15 +05:30
}
}
function SlGetInfoLicensing($AppId, $SkuId)
{
2025-04-29 22:40:56 +05:30
$dwStatus = 0
$dwGrace = 0
2025-04-16 03:47:15 +05:30
$hrReason = 0
2025-04-29 22:40:56 +05:30
$qwValidity = 0
2025-04-16 03:47:15 +05:30
$cStatus = 0
$pStatus = 0
2025-04-29 22:40:56 +05:30
$hrRet = $Win32::SLGetLicensingStatusInformation(
2025-04-16 03:47:15 +05:30
$hSLC,
[ref][Guid]$AppId,
[ref][Guid]$SkuId,
0,
[ref]$cStatus,
[ref]$pStatus
)
2025-04-29 22:40:56 +05:30
if ($hrRet -NE 0 -Or $cStatus -EQ 0)
2025-04-16 03:47:15 +05:30
{
return
}
[IntPtr]$ppStatus = [Int64]$pStatus + [Int64]40 * ($cStatus - 1)
2025-04-29 22:40:56 +05:30
$dwStatus = $Marshal::ReadInt32($ppStatus, 16)
$dwGrace = $Marshal::ReadInt32($ppStatus, 20)
2025-04-16 03:47:15 +05:30
$hrReason = $Marshal::ReadInt32($ppStatus, 28)
2025-04-29 22:40:56 +05:30
$qwValidity = $Marshal::ReadInt64($ppStatus, 32)
2025-04-16 03:47:15 +05:30
2025-04-29 22:40:56 +05:30
if ($dwStatus -EQ 3)
2025-04-16 03:47:15 +05:30
{
2025-04-29 22:40:56 +05:30
$dwStatus = 5
2025-04-16 03:47:15 +05:30
}
2025-04-29 22:40:56 +05:30
if ($dwStatus -EQ 2)
2025-04-16 03:47:15 +05:30
{
if ($hrReason -EQ 0x4004F00D)
{
2025-04-29 22:40:56 +05:30
$dwStatus = 3
2025-04-16 03:47:15 +05:30
}
elseif ($hrReason -EQ 0x4004F065)
{
2025-04-29 22:40:56 +05:30
$dwStatus = 4
2025-04-16 03:47:15 +05:30
}
elseif ($hrReason -EQ 0x4004FC06)
{
2025-04-29 22:40:56 +05:30
$dwStatus = 6
2024-07-13 04:46:38 +05:30
}
}
2025-04-16 03:47:15 +05:30
return
}
2024-07-13 04:46:38 +05:30
2025-04-16 03:47:15 +05:30
function SlGetInfoSLID($AppId)
{
$cReturnIds = 0
$pReturnIds = 0
2025-04-29 22:40:56 +05:30
$hrRet = $Win32::SLGetSLIDList(
2025-04-16 03:47:15 +05:30
$hSLC,
0,
[ref][Guid]$AppId,
1,
[ref]$cReturnIds,
[ref]$pReturnIds
)
2025-04-29 22:40:56 +05:30
if ($hrRet -NE 0 -Or $cReturnIds -EQ 0)
2025-04-16 03:47:15 +05:30
{
return
}
$a1List = @()
$a2List = @()
$a3List = @()
$a4List = @()
foreach ($i in 0..($cReturnIds - 1))
{
$bytes = New-Object byte[] 16
$Marshal::Copy([Int64]$pReturnIds + [Int64]16 * $i, $bytes, 0, 16)
$actid = ([Guid]$bytes).Guid
2025-04-29 22:40:56 +05:30
$gPPK = SlGetInfoSku $actid "pkeyId"
$gAdd = SlGetInfoSku $actid "DependsOn"
2025-04-16 03:47:15 +05:30
if ($All.IsPresent) {
2025-04-29 22:40:56 +05:30
if ($null -EQ $gPPK -And $null -NE $gAdd) { $a1List += @{id = $actid; pk = $null; ex = $true} }
if ($null -EQ $gPPK -And $null -EQ $gAdd) { $a2List += @{id = $actid; pk = $null; ex = $false} }
2025-04-16 03:47:15 +05:30
}
2025-04-29 22:40:56 +05:30
if ($null -NE $gPPK -And $null -NE $gAdd) { $a3List += @{id = $actid; pk = $gPPK; ex = $true} }
if ($null -NE $gPPK -And $null -EQ $gAdd) { $a4List += @{id = $actid; pk = $gPPK; ex = $false} }
2025-04-16 03:47:15 +05:30
}
return ($a1List + $a2List + $a3List + $a4List)
2024-07-13 04:46:38 +05:30
}
function DetectSubscription {
2025-04-16 03:47:15 +05:30
try
{
$objSvc = New-Object PSObject
$wmiSvc = [wmisearcher]"SELECT SubscriptionType, SubscriptionStatus, SubscriptionEdition, SubscriptionExpiry FROM SoftwareLicensingService"
$wmiSvc.Options.Rewindable = $false
$wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { $objSvc | Add-Member 8 $_.Name $_.Value }
$wmiSvc.Dispose()
}
catch
{
return
}
2024-07-13 04:46:38 +05:30
if ($null -EQ $objSvc.SubscriptionType -Or $objSvc.SubscriptionType -EQ 120) {
return
}
if ($objSvc.SubscriptionType -EQ 1) {
$SubMsgType = "Device based"
} else {
$SubMsgType = "User based"
}
if ($objSvc.SubscriptionStatus -EQ 120) {
$SubMsgStatus = "Expired"
} elseif ($objSvc.SubscriptionStatus -EQ 100) {
$SubMsgStatus = "Disabled"
} elseif ($objSvc.SubscriptionStatus -EQ 1) {
$SubMsgStatus = "Active"
} else {
$SubMsgStatus = "Not active"
}
$SubMsgExpiry = "Unknown"
if ($objSvc.SubscriptionExpiry) {
if ($objSvc.SubscriptionExpiry.Contains("unspecified" ) -EQ $false) {$SubMsgExpiry = $objSvc.SubscriptionExpiry}
}
$SubMsgEdition = "Unknown"
if ($objSvc.SubscriptionEdition) {
if ($objSvc.SubscriptionEdition.Contains("UNKNOWN" ) -EQ $false) {$SubMsgEdition = $objSvc.SubscriptionEdition}
}
2025-01-30 02:25:04 +05:30
CONOUT "`nSubscription information:"
CONOUT " Type : $SubMsgType"
CONOUT " Status : $SubMsgStatus"
2025-04-16 03:47:15 +05:30
CONOUT " Edition: $SubMsgEdition"
2025-01-30 02:25:04 +05:30
CONOUT " Expiry : $SubMsgExpiry"
}
function DetectAdbaClient
{
2025-04-29 22:40:56 +05:30
$propADBA | foreach { set $_ (SlGetInfoSku $licID $_) }
2025-11-11 14:46:32 +05:30
DetectActType
2025-01-30 02:25:04 +05:30
CONOUT "`nAD Activation client information:"
CONOUT " Object Name: $ADActivationObjectName"
CONOUT " Domain Name: $ADActivationObjectDN"
2025-04-16 03:47:15 +05:30
CONOUT " CSVLK Extended PID: $ADActivationCsvlkPID"
CONOUT " CSVLK Activation ID: $ADActivationCsvlkSkuID"
2024-07-13 04:46:38 +05:30
}
function DetectAvmClient
{
2025-04-29 22:40:56 +05:30
$propAVMA | foreach { set $_ (SlGetInfoSku $licID $_) }
2025-01-30 02:25:04 +05:30
CONOUT "`nAutomatic VM Activation client information:"
2025-04-16 03:47:15 +05:30
if (-Not [String]::IsNullOrEmpty($InheritedActivationId)) {
CONOUT " Guest IAID: $InheritedActivationId"
2024-07-13 04:46:38 +05:30
} else {
2025-01-30 02:25:04 +05:30
CONOUT " Guest IAID: Not Available"
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if (-Not [String]::IsNullOrEmpty($InheritedActivationHostMachineName)) {
CONOUT " Host machine name: $InheritedActivationHostMachineName"
2024-07-13 04:46:38 +05:30
} else {
2025-01-30 02:25:04 +05:30
CONOUT " Host machine name: Not Available"
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if (-Not [String]::IsNullOrEmpty($InheritedActivationHostDigitalPid2)) {
CONOUT " Host Digital PID2: $InheritedActivationHostDigitalPid2"
2024-07-13 04:46:38 +05:30
} else {
2025-04-16 03:47:15 +05:30
CONOUT " Host Digital PID2: Not Available"
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ($InheritedActivationActivationTime) {
$IAAT = [DateTime]::FromFileTime($InheritedActivationActivationTime).ToString('yyyy-MM-dd hh:mm:ss tt')
CONOUT " Activation time: $IAAT"
2024-07-13 04:46:38 +05:30
} else {
2025-04-16 03:47:15 +05:30
CONOUT " Activation time: Not Available"
2024-07-13 04:46:38 +05:30
}
}
function DetectKmsHost
{
2025-04-16 03:47:15 +05:30
$IsKeyManagementService = SlGetInfoSvcApp $strApp 'IsKeyManagementService'
if (-Not $IsKeyManagementService) {
return
}
2024-07-13 04:46:38 +05:30
if ($Vista -Or $NT5) {
2025-04-16 03:47:15 +05:30
$regk = $SLKeyPath
} elseif ($strSLP -EQ $oslp) {
$regk = $OPKeyPath
2024-07-13 04:46:38 +05:30
} else {
2025-04-16 03:47:15 +05:30
$regk = $SPKeyPath
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
$KMSListening = strGetRegistry $regk "KeyManagementServiceListeningPort"
$KMSPublishing = strGetRegistry $regk "DisableDnsPublishing"
$KMSPriority = strGetRegistry $regk "EnableKmsLowPriority"
2024-07-13 04:46:38 +05:30
2025-04-16 03:47:15 +05:30
if (-Not $KMSListening) {$KMSListening = 1688}
if (-Not $KMSPublishing) {$KMSPublishing = "TRUE"} else {$KMSPublishing = BoolToWStr (!$KMSPublishing)}
if (-Not $KMSPriority) {$KMSPriority = "FALSE"} else {$KMSPriority = BoolToWStr $KMSPriority}
if ($KMSPublishing -EQ "TRUE") {$KMSPublishing = "Enabled"} else {$KMSPublishing = "Disabled"}
if ($KMSPriority -EQ "TRUE") {$KMSPriority = "Low"} else {$KMSPriority = "Normal"}
if ($SLApp)
{
$propKMSServer | foreach { set $_ (SlGetInfoApp $strApp $_) }
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
else
{
$propKMSServer | foreach { set $_ (SlGetInfoService $_) }
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
$KMSRequests = $KeyManagementServiceTotalRequests
$NoRequests = ($null -EQ $KMSRequests) -Or ($KMSRequests -EQ -1) -Or ($KMSRequests -EQ 4294967295)
2025-01-30 02:25:04 +05:30
CONOUT "`nKey Management Service host information:"
CONOUT " Current count: $KeyManagementServiceCurrentCount"
2025-04-16 03:47:15 +05:30
CONOUT " Listening on Port: $KMSListening"
CONOUT " DNS publishing: $KMSPublishing"
CONOUT " KMS priority: $KMSPriority"
if ($NoRequests) {
return
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
CONOUT "`nKey Management Service cumulative requests received from clients:"
CONOUT " Total: $KeyManagementServiceTotalRequests"
CONOUT " Failed: $KeyManagementServiceFailedRequests"
CONOUT " Unlicensed: $KeyManagementServiceUnlicensedRequests"
CONOUT " Licensed: $KeyManagementServiceLicensedRequests"
CONOUT " Initial grace period: $KeyManagementServiceOOBGraceRequests"
CONOUT " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests"
CONOUT " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests"
if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT " Notification: $KeyManagementServiceNotificationRequests"}
2024-07-13 04:46:38 +05:30
}
2025-11-11 14:46:32 +05:30
function DetectActType
2024-07-13 04:46:38 +05:30
{
2025-11-11 14:46:32 +05:30
$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp + '\' + $licID) "VLActivationType"
if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp) "VLActivationType"}
if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath) "VLActivationType"}
if ($null -EQ $VLType -Or $VLType -GT 3) {$VLType = 0}
2025-04-16 03:47:15 +05:30
if ($null -NE $VLType) {CONOUT "Configured Activation Type: $($VLActTypes[$VLType])"}
2025-11-11 14:46:32 +05:30
}
2025-04-16 03:47:15 +05:30
2025-11-11 14:46:32 +05:30
function DetectKmsClient
{
if ($win8) {DetectActType}
2025-01-30 02:25:04 +05:30
CONOUT "`r"
2024-07-13 04:46:38 +05:30
if ($LicenseStatus -NE 1) {
2025-01-30 02:25:04 +05:30
CONOUT "Please activate the product in order to update KMS client information values."
2024-07-13 04:46:38 +05:30
return
}
2025-04-16 03:47:15 +05:30
if ($NT7 -Or $strSLP -EQ $oslp) {
2025-04-29 22:40:56 +05:30
$propKMSClient | foreach { set $_ (SlGetInfoSku $licID $_) }
2025-04-16 03:47:15 +05:30
if ($strSLP -EQ $oslp) {$regk = $OPKeyPath} else {$regk = $SPKeyPath}
$KMSCaching = strGetRegistry $regk "DisableKeyManagementServiceHostCaching"
if (-Not $KMSCaching) {$KMSCaching = "TRUE"} else {$KMSCaching = BoolToWStr (!$KMSCaching)}
}
"ClientMachineID" | foreach { set $_ (SlGetInfoService $_) }
2024-07-13 04:46:38 +05:30
if ($Vista) {
2025-04-16 03:47:15 +05:30
$propKMSVista | foreach { set $_ (SlGetInfoService $_) }
2024-07-13 04:46:38 +05:30
$KeyManagementServicePort = strGetRegistry $SLKeyPath "KeyManagementServicePort"
2025-04-16 03:47:15 +05:30
$DiscoveredKeyManagementServiceName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName"
$DiscoveredKeyManagementServicePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort"
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ([String]::IsNullOrEmpty($KeyManagementServiceName)) {
2024-07-13 04:46:38 +05:30
$KmsReg = $null
} else {
if (-Not $KeyManagementServicePort) {$KeyManagementServicePort = 1688}
2025-04-16 03:47:15 +05:30
$KmsReg = "Registered KMS machine name: ${KeyManagementServiceName}:${KeyManagementServicePort}"
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceName)) {
2024-07-13 04:46:38 +05:30
$KmsDns = "DNS auto-discovery: KMS name not available"
if ($Vista -And -Not $Admin) {$KmsDns = "DNS auto-discovery: Run the script as administrator to retrieve info"}
} else {
2025-04-16 03:47:15 +05:30
if (-Not $DiscoveredKeyManagementServicePort) {$DiscoveredKeyManagementServicePort = 1688}
$KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceName}:${DiscoveredKeyManagementServicePort}"
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ($null -NE $KMSCaching) {
if ($KMSCaching -EQ "TRUE") {$KMSCaching = "Enabled"} else {$KMSCaching = "Disabled"}
}
if ($strSLP -EQ $wslp -And $NT9) {
if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceIpAddress)) {
$DiscoveredKeyManagementServiceIpAddress = "not available"
2024-07-13 04:46:38 +05:30
}
}
2025-01-30 02:25:04 +05:30
CONOUT "Key Management Service client information:"
2025-04-16 03:47:15 +05:30
CONOUT " Client Machine ID (CMID): $ClientMachineID"
2024-07-13 04:46:38 +05:30
if ($null -EQ $KmsReg) {
2025-01-30 02:25:04 +05:30
CONOUT " $KmsDns"
CONOUT " Registered KMS machine name: KMS name not available"
2024-07-13 04:46:38 +05:30
} else {
2025-01-30 02:25:04 +05:30
CONOUT " $KmsReg"
}
2025-04-16 03:47:15 +05:30
if ($null -NE $DiscoveredKeyManagementServiceIpAddress) {CONOUT " KMS machine IP address: $DiscoveredKeyManagementServiceIpAddress"}
CONOUT " KMS machine extended PID: $CustomerPID"
2025-01-30 02:25:04 +05:30
CONOUT " Activation interval: $VLActivationInterval minutes"
CONOUT " Renewal interval: $VLRenewalInterval minutes"
2025-04-16 03:47:15 +05:30
if ($null -NE $KMSCaching) {CONOUT " KMS host caching: $KMSCaching"}
2025-01-30 02:25:04 +05:30
if (-Not [String]::IsNullOrEmpty($KeyManagementServiceLookupDomain)) {CONOUT " KMS SRV record lookup domain: $KeyManagementServiceLookupDomain"}
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
function GetResult($strSLP, $strApp, $entry)
2024-07-13 04:46:38 +05:30
{
2025-04-29 22:40:56 +05:30
$licID = $entry.id
$propPrd | foreach { set $_ (SlGetInfoSku $licID $_) }
. SlGetInfoLicensing $strApp $licID
$LicenseStatus = $dwStatus
$LicReason = $hrReason
$EvaluationEndDate = $qwValidity
$gprMnt = $dwGrace
$pkid = $entry.pk
$isPPK = $null -NE $pkid
$add_on = $Name.IndexOf("add-on for" , 5)
if ($add_on -NE -1) {
$Name = $Name.Substring(0, $add_on + 7)
}
$licPHN = "empty"
if ($Dlv -Or $All.IsPresent) {
$licPHN = SlGetInfoSku $licID "msft:sl/EUL/PHONE/PUBLIC"
}
if ($LicenseStatus -EQ 0 -And !$isPPK) {
& $isAll
CONOUT "Name: $Name"
CONOUT "Description: $Description"
CONOUT "Activation ID: $licID"
CONOUT "License Status: Unlicensed"
if ($licPHN -NE "empty") {
$gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true
CONOUT "Phone activatable: $($gPHN.ToString())"
}
return
}
2024-07-13 04:46:38 +05:30
2025-04-16 03:47:15 +05:30
$winID = ($strApp -EQ $winApp)
$winPR = ($winID -And -Not $entry.ex)
2024-07-13 04:46:38 +05:30
$Vista = ($winID -And $NT6 -And -Not $NT7)
$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
2025-04-29 22:40:56 +05:30
$win8 = ($strSLP -EQ $wslp -And $NT8)
2025-01-30 02:25:04 +05:30
$reapp = ("Windows" , "App" )[!$winID]
$prmnt = ("machine" , "product" )[!$winPR]
2024-07-13 04:46:38 +05:30
2025-04-29 22:40:56 +05:30
if ($Description.Contains("VOLUME_KMSCLIENT" )) {$cKmsClient = 1; $actTag = "Volume"}
if ($Description.Contains("TIMEBASED_" )) {$cTblClient = 1; $actTag = "Timebased"}
if ($Description.Contains("VIRTUAL_MACHINE_ACTIVATION" )) {$cAvmClient = 1; $actTag = "Automatic VM"}
if ($null -EQ $cKmsClient -And $Description.Contains("VOLUME_KMS")) {$cKmsServer = 1}
2024-07-13 04:46:38 +05:30
2025-04-29 22:40:56 +05:30
$gprDay = [Math]::Round($gprMnt/1440)
$_xpr = ""
$inGrace = $false
if ($gprMnt -GT 0) {
$_xpr = [DateTime]::Now.AddMinutes($gprMnt).ToString('yyyy-MM-dd hh:mm:ss tt')
$inGrace = $true
2024-07-13 04:46:38 +05:30
}
2025-04-29 22:40:56 +05:30
$LicenseMsg = "Time remaining: $gprMnt minute(s) ($gprDay day(s))"
2024-07-13 04:46:38 +05:30
if ($LicenseStatus -EQ 0) {
$LicenseInf = "Unlicensed"
$LicenseMsg = $null
}
if ($LicenseStatus -EQ 1) {
$LicenseInf = "Licensed"
2025-04-29 22:40:56 +05:30
if ($gprMnt -EQ 0) {
2025-04-16 03:47:15 +05:30
$LicenseMsg = $null
2025-01-30 02:25:04 +05:30
$ExpireMsg = "The $prmnt is permanently activated."
2024-07-13 04:46:38 +05:30
} else {
2025-04-29 22:40:56 +05:30
$LicenseMsg = "$actTag activation expiration: $gprMnt minute(s) ($gprDay day(s))"
if ($inGrace) {$ExpireMsg = "$actTag activation will expire $_xpr"}
2024-07-13 04:46:38 +05:30
}
}
if ($LicenseStatus -EQ 2) {
$LicenseInf = "Initial grace period"
2025-04-29 22:40:56 +05:30
if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"}
2024-07-13 04:46:38 +05:30
}
if ($LicenseStatus -EQ 3) {
$LicenseInf = "Additional grace period (KMS license expired or hardware out of tolerance)"
2025-04-29 22:40:56 +05:30
if ($inGrace) {$ExpireMsg = "Additional grace period ends $_xpr"}
2024-07-13 04:46:38 +05:30
}
if ($LicenseStatus -EQ 4) {
$LicenseInf = "Non-genuine grace period"
2025-04-29 22:40:56 +05:30
if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"}
2024-07-13 04:46:38 +05:30
}
if ($LicenseStatus -EQ 5 -And -Not $NT5) {
2025-04-29 22:40:56 +05:30
$LicenseReason = '0x{0:X}' -f $LicReason
2024-07-13 04:46:38 +05:30
$LicenseInf = "Notification"
$LicenseMsg = "Notification Reason: $LicenseReason"
2025-01-30 02:25:04 +05:30
if ($LicenseReason -EQ "0xC004F00F") {if ($null -NE $cKmsClient) {$LicenseMsg = $LicenseMsg + " (KMS license expired)."} else {$LicenseMsg = $LicenseMsg + " (hardware out of tolerance)."}}
2024-07-13 04:46:38 +05:30
if ($LicenseReason -EQ "0xC004F200") {$LicenseMsg = $LicenseMsg + " (non-genuine)."}
2025-01-30 02:25:04 +05:30
if ($LicenseReason -EQ "0xC004F009" -Or $LicenseReason -EQ "0xC004F064") {$LicenseMsg = $LicenseMsg + " (grace time expired)."}
2024-07-13 04:46:38 +05:30
}
if ($LicenseStatus -GT 5 -Or ($LicenseStatus -GT 4 -And $NT5)) {
$LicenseInf = "Unknown"
$LicenseMsg = $null
}
if ($LicenseStatus -EQ 6 -And -Not $Vista -And -Not $NT5) {
$LicenseInf = "Extended grace period"
2025-04-29 22:40:56 +05:30
if ($inGrace) {$ExpireMsg = "$LicenseInf ends $_xpr"}
2024-07-13 04:46:38 +05:30
}
2025-04-29 22:40:56 +05:30
if ($isPPK) {
2025-04-16 03:47:15 +05:30
$propPkey | foreach { set $_ (SlGetInfoPKey $pkid $_) }
}
2025-04-29 22:40:56 +05:30
if ($winPR -And $isPPK -And -Not $NT8) {
$uxd = SlGetInfoSku $licID 'UXDifferentiator'
2025-04-16 03:47:15 +05:30
$script:primary += @{
2025-04-29 22:40:56 +05:30
aid = $licID;
2025-04-16 03:47:15 +05:30
ppk = $PartialProductKey;
chn = $Channel;
lst = $LicenseStatus;
2025-04-29 22:40:56 +05:30
lcr = $LicReason;
ged = $gprMnt;
2025-04-16 03:47:15 +05:30
evl = $EvaluationEndDate;
dff = $uxd
2024-07-13 04:46:38 +05:30
}
}
2025-04-29 22:40:56 +05:30
if ($IID -And $isPPK) {
$OfflineInstallationId = SlGetInfoIID $licID
2025-04-16 03:47:15 +05:30
}
if ($Dlv) {
2025-04-29 22:40:56 +05:30
if ($win8)
2025-01-30 02:25:04 +05:30
{
2025-04-29 22:40:56 +05:30
$RemainingSkuReArmCount = SlGetInfoSku $licID 'RemainingRearmCount'
2025-04-16 03:47:15 +05:30
$RemainingAppReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount'
2025-01-30 02:25:04 +05:30
}
2025-04-16 03:47:15 +05:30
else
2025-01-30 02:25:04 +05:30
{
2025-04-16 03:47:15 +05:30
if (($winID -And $NT7) -Or $strSLP -EQ $oslp)
{
$RemainingSLReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount'
}
else
{
$RemainingSLReArmCount = SlGetInfoService 'RearmCount'
}
2025-01-30 02:25:04 +05:30
}
2025-04-16 03:47:15 +05:30
if ($null -EQ $TrustedTime)
{
$TrustedTime = SlGetInfoSvcApp $strApp 'TrustedTime'
}
}
2025-01-30 02:25:04 +05:30
& $isAll
2025-04-29 22:40:56 +05:30
CONOUT "Name: $Name"
2025-01-30 02:25:04 +05:30
CONOUT "Description: $Description"
2025-04-29 22:40:56 +05:30
CONOUT "Activation ID: $licID"
2025-04-16 03:47:15 +05:30
if ($null -NE $DigitalPID) {CONOUT "Extended PID: $DigitalPID"}
if ($null -NE $DigitalPID2 -And $Dlv) {CONOUT "Product ID: $DigitalPID2"}
2025-01-30 02:25:04 +05:30
if ($null -NE $OfflineInstallationId -And $IID) {CONOUT "Installation ID: $OfflineInstallationId"}
2025-04-16 03:47:15 +05:30
if ($null -NE $Channel) {CONOUT "Product Key Channel: $Channel"}
2025-01-30 02:25:04 +05:30
if ($null -NE $PartialProductKey) {CONOUT "Partial Product Key: $PartialProductKey"}
CONOUT "License Status: $LicenseInf"
if ($null -NE $LicenseMsg) {CONOUT "$LicenseMsg"}
2025-04-16 03:47:15 +05:30
if ($LicenseStatus -NE 0 -And $EvaluationEndDate) {
$EED = [DateTime]::FromFileTimeUtc($EvaluationEndDate).ToString('yyyy-MM-dd hh:mm:ss tt')
2025-01-30 02:25:04 +05:30
CONOUT "Evaluation End Date: $EED UTC"
}
2025-04-29 22:40:56 +05:30
if ($LicenseStatus -NE 1 -And $licPHN -NE "empty") {
$gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true
CONOUT "Phone activatable: $($gPHN.ToString())"
2025-04-16 03:47:15 +05:30
}
2025-01-30 02:25:04 +05:30
if ($Dlv) {
2025-04-16 03:47:15 +05:30
if ($null -NE $RemainingSLReArmCount) {
CONOUT "Remaining $reapp rearm count: $RemainingSLReArmCount"
2025-01-30 02:25:04 +05:30
}
2025-04-16 03:47:15 +05:30
if ($null -NE $RemainingSkuReArmCount) {
2025-01-30 02:25:04 +05:30
CONOUT "Remaining $reapp rearm count: $RemainingAppReArmCount"
CONOUT "Remaining SKU rearm count: $RemainingSkuReArmCount"
}
2025-04-16 03:47:15 +05:30
if ($LicenseStatus -NE 0 -And $TrustedTime) {
$TTD = [DateTime]::FromFileTime($TrustedTime).ToString('yyyy-MM-dd hh:mm:ss tt')
2025-01-30 02:25:04 +05:30
CONOUT "Trusted time: $TTD"
}
}
2025-04-29 22:40:56 +05:30
if (!$isPPK) {
2025-01-30 02:25:04 +05:30
return
}
2025-04-29 22:40:56 +05:30
if ($win8 -And $VLActivationType -EQ 1) {
2025-01-30 02:25:04 +05:30
DetectAdbaClient
2025-11-11 14:46:32 +05:30
$cKmsClient = $null
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ($winID -And $null -NE $cAvmClient) {
2024-07-13 04:46:38 +05:30
DetectAvmClient
}
2025-04-29 22:40:56 +05:30
$chkSub = ($winPR -And $isSub)
2024-07-13 04:46:38 +05:30
2025-04-16 03:47:15 +05:30
$chkSLS = ($null -NE $cKmsClient -Or $null -NE $cKmsServer -Or $chkSub)
2024-07-13 04:46:38 +05:30
if (!$chkSLS) {
2025-01-30 02:25:04 +05:30
if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"}
2024-07-13 04:46:38 +05:30
return
}
if ($null -NE $cKmsClient) {
DetectKmsClient
}
2025-04-29 22:40:56 +05:30
if ($null -NE $cKmsServer) {
if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"}
DetectKmsHost
} else {
2025-01-30 02:25:04 +05:30
if ($null -NE $ExpireMsg) {CONOUT "`n $ExpireMsg"}
}
2024-07-13 04:46:38 +05:30
if ($chkSub) {
DetectSubscription
}
}
2025-04-16 03:47:15 +05:30
function ParseList($strSLP, $strApp, $arrList)
{
foreach ($entry in $arrList)
{
GetResult $strSLP $strApp $entry
CONOUT "$line3"
& $noAll
}
}
2024-07-13 04:46:38 +05:30
#endregion
#region vNextDiag
if ($PSVersionTable.PSVersion.Major -Lt 3)
{
function ConvertFrom-Json
{
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline=$true)][Object]$item
)
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions" )
$psjs = New-Object System.Web.Script.Serialization.JavaScriptSerializer
Return ,$psjs.DeserializeObject($item)
}
function ConvertTo-Json
{
[CmdletBinding()]
Param(
[Parameter(ValueFromPipeline=$true)][Object]$item
)
[void][System.Reflection.Assembly]::LoadWithPartialName("System.Web.Extensions" )
$psjs = New-Object System.Web.Script.Serialization.JavaScriptSerializer
Return $psjs.Serialize($item)
}
}
function PrintModePerPridFromRegistry
{
$vNextRegkey = "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext"
$vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty 'property' -ErrorAction SilentlyContinue | Where-Object -FilterScript {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume" }
If ($null -Eq $vNextPrids)
{
2025-01-30 02:25:04 +05:30
CONOUT "`nNo registry keys found."
2024-07-13 04:46:38 +05:30
Return
}
2025-01-30 02:25:04 +05:30
CONOUT "`r"
2024-07-13 04:46:38 +05:30
$vNextPrids | ForEach `
{
$mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_
Switch ($mode)
{
2 { $mode = "vNext" ; Break }
3 { $mode = "Device" ; Break }
Default { $mode = "Legacy" ; Break }
}
2025-01-30 02:25:04 +05:30
CONOUT "$_ = $mode"
2024-07-13 04:46:38 +05:30
}
}
function PrintSharedComputerLicensing
{
$scaRegKey = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration"
$scaValue = Get-ItemProperty -Path $scaRegKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction SilentlyContinue
$scaRegKey2 = "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing"
$scaValue2 = Get-ItemProperty -Path $scaRegKey2 -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction SilentlyContinue
$scaPolicyKey = "HKLM:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Licensing"
$scaPolicyValue = Get-ItemProperty -Path $scaPolicyKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction SilentlyContinue
If ($null -Eq $scaValue -And $null -Eq $scaValue2 -And $null -Eq $scaPolicyValue)
{
2025-01-30 02:25:04 +05:30
CONOUT "`nNo registry keys found."
2024-07-13 04:46:38 +05:30
Return
}
$scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue
If ($scaModeValue -Eq 0)
{
$scaMode = "Disabled"
}
If ($scaModeValue -Eq 1)
{
$scaMode = "Enabled"
}
2025-01-30 02:25:04 +05:30
CONOUT "`nStatus: $scaMode"
CONOUT "`r"
2024-07-13 04:46:38 +05:30
$tokenFiles = $null
$tokenPath = "${env:LOCALAPPDATA}\Microsoft\Office\16.0\Licensing"
If (Test-Path $tokenPath)
{
$tokenFiles = Get-ChildItem -Path $tokenPath -Filter "*authString*" -Recurse | Where-Object { !$_.PSIsContainer }
}
2025-02-03 23:57:37 +05:30
If ($null -Eq $tokenFiles -Or $tokenFiles.Length -Eq 0)
2024-07-13 04:46:38 +05:30
{
2025-01-30 02:25:04 +05:30
CONOUT "No tokens found."
2024-07-13 04:46:38 +05:30
Return
}
$tokenFiles | ForEach `
{
$tokenParts = (Get-Content -Encoding Unicode -Path $_.FullName).Split('_')
$output = New-Object PSObject
$output | Add-Member 8 'ACID' $tokenParts[0];
$output | Add-Member 8 'User' $tokenParts[3];
$output | Add-Member 8 'NotBefore' $tokenParts[4];
$output | Add-Member 8 'NotAfter' $tokenParts[5];
Write-Output $output
}
}
function PrintLicensesInformation
{
Param(
[ValidateSet("NUL" , "Device" )]
[String]$mode
)
If ($mode -Eq "NUL")
{
$licensePath = "${env:LOCALAPPDATA}\Microsoft\Office\Licenses"
}
ElseIf ($mode -Eq "Device" )
{
$licensePath = "${env:PROGRAMDATA}\Microsoft\Office\Licenses"
}
$licenseFiles = $null
If (Test-Path $licensePath)
{
$licenseFiles = Get-ChildItem -Path $licensePath -Recurse | Where-Object { !$_.PSIsContainer }
}
2025-01-30 02:25:04 +05:30
If ($null -Eq $licenseFiles -Or $licenseFiles.Length -Eq 0)
2024-07-13 04:46:38 +05:30
{
2025-01-30 02:25:04 +05:30
CONOUT "`nNo licenses found."
2024-07-13 04:46:38 +05:30
Return
}
$licenseFiles | ForEach `
{
$license = (Get-Content -Encoding Unicode $_.FullName | ConvertFrom-Json).License
$decodedLicense = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($license)) | ConvertFrom-Json
$licenseType = $decodedLicense.LicenseType
If ($null -Ne $decodedLicense.ExpiresOn)
{
$expiry = [System.DateTime]::Parse($decodedLicense.ExpiresOn, $null, 'AdjustToUniversal')
}
Else
{
$expiry = New-Object System.DateTime
}
$licenseState = "Grace"
If ((Get-Date) -Gt (Get-Date $decodedLicense.Metadata.NotAfter))
{
$licenseState = "RFM"
}
ElseIf ((Get-Date) -Lt (Get-Date $expiry))
{
$licenseState = "Licensed"
}
$output = New-Object PSObject
$output | Add-Member 8 'File' $_.PSChildName;
$output | Add-Member 8 'Version' $_.Directory.Name;
$output | Add-Member 8 'Type' "User|${licenseType}" ;
$output | Add-Member 8 'Product' $decodedLicense.ProductReleaseId;
$output | Add-Member 8 'Acid' $decodedLicense.Acid;
If ($mode -Eq "Device") { $output | Add-Member 8 'DeviceId' $decodedLicense.Metadata.DeviceId; }
$output | Add-Member 8 'LicenseState' $licenseState;
$output | Add-Member 8 'EntitlementStatus' $decodedLicense.Status;
$output | Add-Member 8 'EntitlementExpiration' ("N/A" , $decodedLicense.ExpiresOn)[!($null -eq $decodedLicense.ExpiresOn)];
$output | Add-Member 8 'ReasonCode' ("N/A" , $decodedLicense.ReasonCode)[!($null -eq $decodedLicense.ReasonCode)];
$output | Add-Member 8 'NotBefore' $decodedLicense.Metadata.NotBefore;
$output | Add-Member 8 'NotAfter' $decodedLicense.Metadata.NotAfter;
$output | Add-Member 8 'NextRenewal' $decodedLicense.Metadata.RenewAfter;
$output | Add-Member 8 'TenantId' ("N/A" , $decodedLicense.Metadata.TenantId)[!($null -eq $decodedLicense.Metadata.TenantId)];
#$output.PSObject.Properties | foreach { $ht = @{} } { $ht[$_.Name] = $_.Value } { $output = $ht | ConvertTo-Json }
Write-Output $output
}
}
function vNextDiagRun
{
2025-05-06 18:09:33 +05:30
$fNUL = ([IO.Directory]::Exists("${env:LOCALAPPDATA}\Microsoft\Office\Licenses" )) -and ([IO.Directory]::GetFiles("${env:LOCALAPPDATA}\Microsoft\Office\Licenses" , "*" , 1).Length -GT 0)
$fDev = ([IO.Directory]::Exists("${env:PROGRAMDATA}\Microsoft\Office\Licenses" )) -and ([IO.Directory]::GetFiles("${env:PROGRAMDATA}\Microsoft\Office\Licenses" , "*" , 1).Length -GT 0)
2024-07-13 04:46:38 +05:30
$rPID = $null -NE (GP "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext" -EA 0 | select -Expand 'property' -EA 0 | where -Filter {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume" })
$rSCA = $null -NE (GP "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration" -EA 0 | select -Expand "SharedComputerLicensing" -EA 0)
$rSCL = $null -NE (GP "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing" -EA 0 | select -Expand "SharedComputerLicensing" -EA 0)
if (($fNUL -Or $fDev -Or $rPID -Or $rSCA -Or $rSCL) -EQ $false) {
Return
}
2025-01-30 02:25:04 +05:30
& $isAll
CONOUT "$line2"
CONOUT "=== Office vNext Status ==="
CONOUT "$line2"
CONOUT "`n========== Mode per ProductReleaseId =========="
2024-07-13 04:46:38 +05:30
PrintModePerPridFromRegistry
2025-01-30 02:25:04 +05:30
CONOUT "`n========== Shared Computer Licensing =========="
2024-07-13 04:46:38 +05:30
PrintSharedComputerLicensing
2025-01-30 02:25:04 +05:30
CONOUT "`n========== vNext licenses ==========="
2024-07-13 04:46:38 +05:30
PrintLicensesInformation -Mode "NUL"
2025-01-30 02:25:04 +05:30
CONOUT "`n========== Device licenses =========="
2024-07-13 04:46:38 +05:30
PrintLicensesInformation -Mode "Device"
2025-01-30 02:25:04 +05:30
CONOUT "$line3"
CONOUT "`r"
2024-07-13 04:46:38 +05:30
}
#endregion
#region clic
< #
;;; Source: https://github.com/asdcorp/clic
;;; Powershell port: abbodi1406
Copyright 2023 asdcorp
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software" ), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#>
function InitializeDigitalLicenseCheck {
$CAB = [System.Reflection.Emit.CustomAttributeBuilder]
$ICom = $Module.DefineType('EUM.IEUM', 'Public, Interface, Abstract, Import')
$ICom.SetCustomAttribute($CAB::new([System.Runtime.InteropServices.ComImportAttribute].GetConstructor(@()) , @()))
$ICom.SetCustomAttribute($CAB::new([System.Runtime.InteropServices.GuidAttribute].GetConstructor(@([String])) , @('F2DCB80D-0670-44BC-9002-CD18688730AF')))
$ICom.SetCustomAttribute($CAB::new([System.Runtime.InteropServices.InterfaceTypeAttribute].GetConstructor(@([Int16])) , @([Int16]1)))
1..4 | % { [void]$ICom.DefineMethod('VF'+$_, 'Public, Virtual, HideBySig, NewSlot, Abstract', 'Standard, HasThis', [Void], @()) }
[void]$ICom.DefineMethod('AcquireModernLicenseForWindows', 1478, 33, [Int32], @([Int32], [Int32].MakeByRefType()))
$IEUM = $ICom.CreateType()
}
function PrintStateData {
$pwszStateData = 0
$cbSize = 0
if ($Win32::SLGetWindowsInformation(
"Security-SPP-Action-StateData" ,
[ref]$null,
[ref]$cbSize,
[ref]$pwszStateData
)) {
return $FALSE
}
[string[]]$pwszStateString = $Marshal::PtrToStringUni($pwszStateData) -replace ";" , "`n "
2025-01-30 02:25:04 +05:30
CONOUT (" $pwszStateString" )
2024-07-13 04:46:38 +05:30
$Marshal::FreeHGlobal($pwszStateData)
return $TRUE
}
2025-01-30 02:25:04 +05:30
function PrintLastActivationHResult {
2024-07-13 04:46:38 +05:30
$pdwLastHResult = 0
$cbSize = 0
if ($Win32::SLGetWindowsInformation(
"Security-SPP-LastWindowsActivationHResult" ,
[ref]$null,
[ref]$cbSize,
[ref]$pdwLastHResult
)) {
return $FALSE
}
2025-01-30 02:25:04 +05:30
CONOUT (" LastActivationHResult=0x{0:x8}" -f $Marshal::ReadInt32($pdwLastHResult))
2024-07-13 04:46:38 +05:30
$Marshal::FreeHGlobal($pdwLastHResult)
return $TRUE
}
2025-01-30 02:25:04 +05:30
function PrintLastActivationTime {
2025-04-16 03:47:15 +05:30
$pqwLastTime = 0
2025-01-30 02:25:04 +05:30
$cbSize = 0
if ($Win32::SLGetWindowsInformation(
"Security-SPP-LastWindowsActivationTime" ,
[ref]$null,
[ref]$cbSize,
2025-04-16 03:47:15 +05:30
[ref]$pqwLastTime
2025-01-30 02:25:04 +05:30
)) {
return $FALSE
}
2025-04-16 03:47:15 +05:30
$actTime = $Marshal::ReadInt64($pqwLastTime)
2025-01-30 02:25:04 +05:30
if ($actTime -ne 0) {
CONOUT (" LastActivationTime={0}" -f [DateTime]::FromFileTimeUtc($actTime).ToString("yyyy/MM/dd:HH:mm:ss" ))
}
2025-04-16 03:47:15 +05:30
$Marshal::FreeHGlobal($pqwLastTime)
2025-01-30 02:25:04 +05:30
return $TRUE
}
2024-07-13 04:46:38 +05:30
function PrintIsWindowsGenuine {
$dwGenuine = 0
if ($Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)) {
return $FALSE
}
if ($dwGenuine -lt 5) {
2025-01-30 02:25:04 +05:30
CONOUT (" IsWindowsGenuine={0}" -f $ppwszGenuineStates[$dwGenuine])
2024-07-13 04:46:38 +05:30
} else {
2025-01-30 02:25:04 +05:30
CONOUT (" IsWindowsGenuine={0}" -f $dwGenuine)
2024-07-13 04:46:38 +05:30
}
return $TRUE
}
function PrintDigitalLicenseStatus {
try {
. InitializeDigitalLicenseCheck
$ComObj = New-Object -Com EditionUpgradeManagerObj.EditionUpgradeManager
} catch {
return $FALSE
}
$parameters = 1, $null
if ([EUM.IEUM].GetMethod("AcquireModernLicenseForWindows" ).Invoke($ComObj, $parameters)) {
return $FALSE
}
$dwReturnCode = $parameters[1]
[bool]$bDigitalLicense = $FALSE
$bDigitalLicense = (($dwReturnCode -ge 0) -and ($dwReturnCode -ne 1))
2025-01-30 02:25:04 +05:30
CONOUT (" IsDigitalLicense={0}" -f (BoolToWStr $bDigitalLicense))
2024-07-13 04:46:38 +05:30
return $TRUE
}
function PrintSubscriptionStatus {
$dwSupported = 0
if ($winbuild -ge 15063) {
$pwszPolicy = "ConsumeAddonPolicySet"
} else {
$pwszPolicy = "Allow-WindowsSubscription"
}
if ($Win32::SLGetWindowsInformationDWORD($pwszPolicy, [ref]$dwSupported)) {
return $FALSE
}
2025-01-30 02:25:04 +05:30
CONOUT (" SubscriptionSupportedEdition={0}" -f (BoolToWStr $dwSupported))
2024-07-13 04:46:38 +05:30
$pStatus = $Marshal::AllocHGlobal($Marshal::SizeOf([Type]$SubStatus))
if ($Win32::ClipGetSubscriptionStatus([ref]$pStatus)) {
return $FALSE
}
$sStatus = [Activator]::CreateInstance($SubStatus)
$sStatus = $Marshal::PtrToStructure($pStatus, [Type]$SubStatus)
$Marshal::FreeHGlobal($pStatus)
2025-01-30 02:25:04 +05:30
CONOUT (" SubscriptionEnabled={0}" -f (BoolToWStr $sStatus.dwEnabled))
2024-07-13 04:46:38 +05:30
if ($sStatus.dwEnabled -eq 0) {
return $TRUE
}
2025-01-30 02:25:04 +05:30
CONOUT (" SubscriptionSku={0}" -f $sStatus.dwSku)
CONOUT (" SubscriptionState={0}" -f $sStatus.dwState)
2024-07-13 04:46:38 +05:30
return $TRUE
}
function ClicRun
{
2025-01-30 02:25:04 +05:30
& $isAll
CONOUT "Client Licensing Check information:"
2024-07-13 04:46:38 +05:30
$null = PrintStateData
2025-01-30 02:25:04 +05:30
$null = PrintLastActivationHResult
$null = PrintLastActivationTime
2024-07-13 04:46:38 +05:30
$null = PrintIsWindowsGenuine
if ($DllDigital) {
$null = PrintDigitalLicenseStatus
}
if ($DllSubscription) {
$null = PrintSubscriptionStatus
}
2025-01-30 02:25:04 +05:30
CONOUT "$line3"
& $noAll
2024-07-13 04:46:38 +05:30
}
#endregion
2025-04-16 03:47:15 +05:30
#region clc
function clcGetExpireKrn
{
$tData = 0
$cData = 0
$bData = 0
2025-04-29 22:40:56 +05:30
$hrRet = $Win32::SLGetWindowsInformation(
2025-04-16 03:47:15 +05:30
"Kernel-ExpirationDate" ,
[ref]$tData,
[ref]$cData,
[ref]$bData
)
2025-04-29 22:40:56 +05:30
if ($hrRet -Or !$cData -Or $tData -NE 3)
2025-04-16 03:47:15 +05:30
{
return $null
}
$year = $Marshal::ReadInt16($bData, 0)
if ($year -EQ 0 -Or $year -EQ 1601)
{
$rData = $null
}
else
{
$rData = '{0}/{1}/{2}:{3}:{4}:{5}' -f $year, $Marshal::ReadInt16($bData, 2), $Marshal::ReadInt16($bData, 4), $Marshal::ReadInt16($bData, 6), $Marshal::ReadInt16($bData, 8), $Marshal::ReadInt16($bData, 10)
}
2025-04-29 22:40:56 +05:30
#$Marshal::FreeHGlobal($bData)
2025-04-16 03:47:15 +05:30
return $rData
}
function clcGetExpireSys
{
$kuser = $Marshal::ReadInt64((New-Object IntPtr(0x7FFE02C8)))
if ($kuser -EQ 0)
{
return $null
}
2025-05-06 18:09:33 +05:30
$rData = [DateTime]::FromFileTimeUtc($kuser).ToString('yyyy/MM/dd:HH:mm:ss')
2025-04-16 03:47:15 +05:30
return $rData
}
function clcGetLicensingState($dwState)
{
if ($dwState -EQ 5) {
$dwState = 3
} elseif ($dwState -EQ 3 -Or $dwState -EQ 4 -Or $dwState -EQ 6) {
$dwState = 2
} elseif ($dwState -GT 6) {
$dwState = 4
}
$rData = '{0}' -f $ppwszLicensingStates[$dwState]
return $rData
}
function clcGetGenuineState($AppId)
{
$dwGenuine = 0
if ($NT7) {
2025-04-29 22:40:56 +05:30
$hrRet = $Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)
2025-04-16 03:47:15 +05:30
} else {
2025-04-29 22:40:56 +05:30
$hrRet = $Win32::SLIsGenuineLocal([ref][Guid]$AppId, [ref]$dwGenuine, 0)
2025-04-16 03:47:15 +05:30
}
2025-04-29 22:40:56 +05:30
if ($hrRet)
2025-04-16 03:47:15 +05:30
{
$dwGenuine = 4
}
if ($dwGenuine -LT 5) {
$rData = '{0}' -f $ppwszGenuineStates[$dwGenuine]
} else {
$rData = $dwGenuine
}
return $rData
}
function ClcRun
{
$prs = $script:primary[0]
if ($null -EQ $prs) {
return
}
$lState = clcGetLicensingState $prs.lst
$uState = clcGetGenuineState $winApp
$TbbKrn = clcGetExpireKrn
$TbbSys = clcGetExpireSys
if ($null -NE $TbbKrn) {
$ked = $TbbKrn
} elseif ($null -NE $TbbSys) {
$ked = $TbbSys
}
& $isAll
CONOUT "Client Licensing Check information:"
CONOUT (" AppId={0}" -f $winApp)
if ($prs.ged) { CONOUT (" GraceEndDate={0}" -f ([DateTime]::UtcNow.AddMinutes($prs.ged).ToString('yyyy/MM/dd:HH:mm:ss'))) }
if ($null -NE $ked) { CONOUT (" KernelTimebombDate={0}" -f $ked) }
CONOUT (" LastConsumptionReason=0x{0:x8}" -f $prs.lcr)
if ($prs.evl) { CONOUT (" LicenseExpirationDate={0}" -f ([DateTime]::FromFileTimeUtc($prs.evl).ToString('yyyy/MM/dd:HH:mm:ss'))) }
CONOUT (" LicenseState={0}" -f $lState)
CONOUT (" PartialProductKey={0}" -f $prs.ppk)
CONOUT (" ProductKeyType={0}" -f $prs.chn)
CONOUT (" SkuId={0}" -f $prs.aid)
CONOUT (" uxDifferentiator={0}" -f $prs.dff)
CONOUT (" IsWindowsGenuine={0}" -f $uState)
CONOUT "$line3"
& $noAll
}
#endregion
2024-07-13 04:46:38 +05:30
$Host.UI.RawUI.WindowTitle = "Check Activation Status"
if ($All.IsPresent) {
2025-01-30 02:25:04 +05:30
$B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B;
if (!$Pass.IsPresent) {clear;}
2024-07-13 04:46:38 +05:30
}
2025-02-03 23:57:37 +05:30
$SysPath = "$env:SystemRoot\System32"
if (Test-Path "$env:SystemRoot\Sysnative\reg.exe") {
$SysPath = "$env:SystemRoot\Sysnative"
}
2024-07-13 04:46:38 +05:30
$wslp = "SoftwareLicensingProduct"
$wsls = "SoftwareLicensingService"
$oslp = "OfficeSoftwareProtectionProduct"
$osls = "OfficeSoftwareProtectionService"
$winApp = "55c92734-d682-4d71-983e-d6ec3f16059f"
$o14App = "59a52881-a989-479d-af46-f275c6370663"
$o15App = "0ff1ce15-a989-479d-af46-f275c6370663"
2025-04-29 22:40:56 +05:30
$isSub = ($winbuild -GE 26000) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType" )
2024-07-13 04:46:38 +05:30
$DllDigital = ($winbuild -GE 14393) -And (Test-Path "$SysPath\EditionUpgradeManagerObj.dll" )
$DllSubscription = ($winbuild -GE 14393) -And (Test-Path "$SysPath\Clipc.dll" )
$VLActTypes = @("All" , "AD" , "KMS" , "Token" )
2025-04-16 03:47:15 +05:30
$OPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
$SPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
2025-01-30 02:25:04 +05:30
$SLKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
$NSKeyPath = "HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
2025-04-16 03:47:15 +05:30
$propPrd = 'Name', 'Description', 'TrustedTime', 'VLActivationType'
$propPkey = 'PartialProductKey', 'Channel', 'DigitalPID', 'DigitalPID2'
$propKMSServer = 'KeyManagementServiceCurrentCount', 'KeyManagementServiceTotalRequests', 'KeyManagementServiceFailedRequests', 'KeyManagementServiceUnlicensedRequests', 'KeyManagementServiceLicensedRequests', 'KeyManagementServiceOOBGraceRequests', 'KeyManagementServiceOOTGraceRequests', 'KeyManagementServiceNonGenuineGraceRequests', 'KeyManagementServiceNotificationRequests'
$propKMSClient = 'CustomerPID', 'KeyManagementServiceName', 'KeyManagementServicePort', 'DiscoveredKeyManagementServiceName', 'DiscoveredKeyManagementServicePort', 'DiscoveredKeyManagementServiceIpAddress', 'VLActivationInterval', 'VLRenewalInterval', 'KeyManagementServiceLookupDomain'
$propKMSVista = 'CustomerPID', 'KeyManagementServiceName', 'VLActivationInterval', 'VLRenewalInterval'
$propADBA = 'ADActivationObjectName', 'ADActivationObjectDN', 'ADActivationCsvlkPID', 'ADActivationCsvlkSkuID'
$propAVMA = 'InheritedActivationId', 'InheritedActivationHostMachineName', 'InheritedActivationHostDigitalPid2', 'InheritedActivationActivationTime'
$primary = @()
$ppwszGenuineStates = @(
"SL_GEN_STATE_IS_GENUINE" ,
"SL_GEN_STATE_INVALID_LICENSE" ,
"SL_GEN_STATE_TAMPERED" ,
"SL_GEN_STATE_OFFLINE" ,
"SL_GEN_STATE_LAST"
)
$ppwszLicensingStates = @(
"SL_LICENSING_STATUS_UNLICENSED" ,
"SL_LICENSING_STATUS_LICENSED" ,
"SL_LICENSING_STATUS_IN_GRACE_PERIOD" ,
"SL_LICENSING_STATUS_NOTIFICATION" ,
"SL_LICENSING_STATUS_LAST"
)
2024-07-13 04:46:38 +05:30
2025-04-16 03:47:15 +05:30
'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ @()}
2024-07-13 04:46:38 +05:30
2025-01-30 02:25:04 +05:30
$offsvc = "osppsvc"
if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"}
2024-07-13 04:46:38 +05:30
2025-01-30 02:25:04 +05:30
try {gsv $winsvc -EA 1 | Out-Null; $WsppHook = 1} catch {$WsppHook = 0}
try {gsv $offsvc -EA 1 | Out-Null; $OsppHook = 1} catch {$OsppHook = 0}
2024-07-13 04:46:38 +05:30
2025-04-16 03:47:15 +05:30
if (Test-Path "$SysPath\sppc.dll") {
$SLdll = 'sppc.dll'
} elseif (Test-Path "$SysPath\slc.dll" ) {
$SLdll = 'slc.dll'
} else {
$WsppHook = 0
2025-01-30 02:25:04 +05:30
}
2024-07-13 04:46:38 +05:30
if ($OsppHook -NE 0) {
2025-04-16 03:47:15 +05:30
$OLdll = (strGetRegistry $OPKeyPath "Path" ) + 'osppc.dll'
if (!(Test-Path "$OLdll")) {$OsppHook = 0}
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ($WsppHook -NE 0) {
if ($NT6 -And -Not $NT7 -And -Not $Admin) {
if ($null -EQ [Diagnostics.Process]::GetProcessesByName("$winsvc")[0].ProcessName) {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"}
} else {
try {sasv $winsvc -EA 1} catch {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n" }
}
}
if ($WsppHook -NE 0) {
. InitializePInvoke $SLdll $false
$hSLC = 0
[void]$Win32::SLOpen([ref]$hSLC)
$cW1nd0ws = SlGetInfoSLID $winApp
$c0ff1ce15 = SlGetInfoSLID $o15App
$c0ff1ce14 = SlGetInfoSLID $o14App
}
if ($cW1nd0ws.Count -GT 0)
2024-07-13 04:46:38 +05:30
{
echoWindows
2025-04-16 03:47:15 +05:30
ParseList $wslp $winApp $cW1nd0ws
2024-07-13 04:46:38 +05:30
}
elseif ($NT6)
{
echoWindows
2025-04-16 03:47:15 +05:30
CONOUT "Error: product key not found.`n"
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ($NT6 -And -Not $NT8) {
ClcRun
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ($NT8) {
ClicRun
2024-07-13 04:46:38 +05:30
}
$doMSG = 1
2025-04-16 03:47:15 +05:30
if ($c0ff1ce15.Count -GT 0)
2025-01-30 02:25:04 +05:30
{
2025-04-16 03:47:15 +05:30
CheckOhook
2024-07-13 04:46:38 +05:30
echoOffice
2025-04-16 03:47:15 +05:30
ParseList $wslp $o15App $c0ff1ce15
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ($c0ff1ce14.Count -GT 0)
2025-01-30 02:25:04 +05:30
{
2024-07-13 04:46:38 +05:30
echoOffice
2025-04-16 03:47:15 +05:30
ParseList $wslp $o14App $c0ff1ce14
}
if ($hSLC) {
[void]$Win32::SLClose($hSLC)
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ($OsppHook -NE 0) {
try {sasv $offsvc -EA 1} catch {$OsppHook = 0; CONOUT "`nError: failed to start $offsvc Service.`n" }
}
if ($OsppHook -NE 0) {
. InitializePInvoke "$OLdll" $true
$hSLC = 0
[void]$Win32::SLOpen([ref]$hSLC)
$ospp15 = SlGetInfoSLID $o15App
$ospp14 = SlGetInfoSLID $o14App
}
if ($ospp15.Count -GT 0)
2025-01-30 02:25:04 +05:30
{
2024-07-13 04:46:38 +05:30
echoOffice
2025-04-16 03:47:15 +05:30
ParseList $oslp $o15App $ospp15
2024-07-13 04:46:38 +05:30
}
2025-04-16 03:47:15 +05:30
if ($ospp14.Count -GT 0)
2025-01-30 02:25:04 +05:30
{
2024-07-13 04:46:38 +05:30
echoOffice
2025-04-16 03:47:15 +05:30
ParseList $oslp $o14App $ospp14
}
if ($hSLC) {
[void]$Win32::SLClose($hSLC)
2024-07-13 04:46:38 +05:30
}
if ($NT7) {
vNextDiagRun
}
ExitScript 0
: sppmgr :