usage Examples part --> Post No' 4 https://forums.mydigitallife.net/threads/89340/#post-1881092 ~~~~~~~~~~~~~~~~~~~~~~~ i sit on this project few days. so you can enum, Instal/uninstall License -or Key get info about SKU etc etc as much low level can get you. ~~~~~~~~~~~~~~~~~~~~~~~ update at 21-06-25 - Add SLGenerateOfflineInstallationId function ~~~~~~~~~~~~~~~~~~~~~~~ Part 1 --> Defination Code: using namespace System using namespace System.Collections.Generic using namespace System.IO using namespace System.IO.Compression using namespace System.Reflection using namespace System.Reflection.Emit using namespace System.Runtime.InteropServices using namespace System.Security.AccessControl using namespace System.Security.Principal using namespace System.ServiceProcess function New-IntPtr { param( [Parameter(Mandatory=$true)] [int]$Size, [Parameter(Mandatory=$false)] [int]$InitialValue = 0, [switch]$WriteSizeAtZero ) # Allocate unmanaged memory $ptr = [Marshal]::AllocHGlobal($Size) # Zero memory $Global:ntdll::RtlZeroMemory.Invoke($ptr, [UIntPtr]::new($Size)) # Write size at offset 0 if requested if ($WriteSizeAtZero) { [Marshal]::WriteInt32($ptr, 0, $Size) } # Otherwise, if size == 4 and initial value != 0, write initial value elseif ($Size -eq 4 -and $InitialValue -ne 0) { [Marshal]::WriteInt32($ptr, 0, $InitialValue) } return $ptr } Function Init-NTDLL { $Method = [PSCustomObject]@{ attributes = [MethodAttributes]::Public -bor [MethodAttributes]::Static -bor [MethodAttributes]::PinvokeImpl CallingConventions = [CallingConventions]::Standard nativeCallConv = [CallingConvention]::Winapi nativeCharSet = [CharSet]::Unicode ImplAttributes = [MethodImplAttributes]::PreserveSig TypeAttributes = [TypeAttributes]::Public -bor [TypeAttributes]::Abstract -bor [TypeAttributes]::Sealed } # Define dynamic type and methods before main try-finally $asmName = New-Object AssemblyName "NativeOSVersionAssembly" $asm = [AppDomain]::CurrentDomain.DefineDynamicAssembly($asmName, [AssemblyBuilderAccess]::Run) $mod = $asm.DefineDynamicModule("NativeOSVersionModule") $tb = $mod.DefineType("NativeMethods", $Method.TypeAttributes) $NtdllFunctions = @( @{ Name = "RtlGetVersion"; Dll = "ntdll.dll"; ReturnType = [int]; Parameters = [IntPtr] }, @{ Name = "RtlGetCurrentPeb"; Dll = "ntdll.dll"; ReturnType = [IntPtr]; Parameters = @() }, @{ Name = "RtlGetProductInfo"; Dll = "ntdll.dll"; ReturnType = [bool]; Parameters = [Type[]]@([UInt32], [UInt32], [UInt32], [UInt32], [IntPtr]) }, @{ Name = "RtlGetNtVersionNumbers"; Dll = "ntdll.dll"; ReturnType = [void]; Parameters = ([IntPtr], [IntPtr], [IntPtr]) }, @{ Name = "RtlZeroMemory"; Dll = "ntdll.dll"; ReturnType = [void]; Parameters = [Type[]]@([IntPtr], [UIntPtr]) }, @{ Name = "RtlGetProcessHeaps"; Dll = "ntdll.dll"; ReturnType = [UInt32]; Parameters = [Type[]]@([UInt32], [IntPtr]) }, @{ Name = "NtQueryInformationProcess"; Dll = "ntdll.dll"; ReturnType = [UInt32]; Parameters = [Type[]]@([IntPtr], [UInt32], [IntPtr], [UInt32], [IntPtr]) }, @{ Name = "NtQuerySystemInformation"; Dll = "ntdll.dll"; ReturnType = [UInt32]; Parameters = [Type[]]@([UInt32], [IntPtr], [UInt32], [IntPtr]) } ) foreach ($func in $NtdllFunctions) { $tb.DefinePInvokeMethod($func.Name, $func.Dll, $Method.attributes, $Method.CallingConventions, $func.ReturnType, $func.Parameters, $Method.nativeCallConv, $Method.nativeCharSet ).SetImplementationFlags($Method.ImplAttributes) } return $tb.CreateType() } Function Init-KERNEL32 { $Method = [PSCustomObject]@{ attributes = [MethodAttributes]::Public -bor [MethodAttributes]::Static -bor [MethodAttributes]::PinvokeImpl CallingConventions = [CallingConventions]::Standard nativeCallConv = [CallingConvention]::Winapi nativeCharSet = [CharSet]::Unicode ImplAttributes = [MethodImplAttributes]::PreserveSig TypeAttributes = [TypeAttributes]::Public -bor [TypeAttributes]::Abstract -bor [TypeAttributes]::Sealed } $asm = [AppDomain]::CurrentDomain.DefineDynamicAssembly( (New-Object System.Reflection.AssemblyName "Kernel32API"), [System.Reflection.Emit.AssemblyBuilderAccess]::Run ) $mod = $asm.DefineDynamicModule("Kernel32APIModule") $tb = $mod.DefineType("NativeMethods", $Method.TypeAttributes) $functions = @( @{ Name = "FindFirstFileW"; Dll = "kernel32.dll"; ReturnType = [IntPtr]; Parameters = [Type[]]@([string], [IntPtr]) }, @{ Name = "FindNextFileW"; Dll = "kernel32.dll"; ReturnType = [bool]; Parameters = [Type[]]@([IntPtr], [IntPtr]) }, @{ Name = "FindClose"; Dll = "kernel32.dll"; ReturnType = [bool]; Parameters = [Type[]]@([IntPtr]) }, @{ Name = "LocalFree" ; Dll = "kernel32.dll"; ReturnType = [IntPtr]; Parameters = [Type[]]@([IntPtr]) } ) foreach ($f in $functions) { $tb.DefinePInvokeMethod($f.Name, $f.Dll, $Method.attributes, $Method.CallingConventions, $f.ReturnType, $f.Parameters, $Method.nativeCallConv, $Method.nativeCharSet ).SetImplementationFlags($Method.ImplAttributes) } return $tb.CreateType() } <# Should be called from -> Slc.dll but work from sppc.dll, osppc.dll maybe Slc.dll call sppc.dll -or osppc.dll Windows 10 DLL File Information - sppc.dll https://windows10dll.nirsoft.net/sppc_dll.html List of files that are statically linked to sppc.dll, slc.dll, etc, etc, This means that when one of the above files is loaded, sppc.dll will be loaded too. (The opposite of the previous 'Static Linking' section) "OSPPC.dll" is a dynamic link library (DLL) file, that is a core component of Microsoft Office's Software Protection Platform. Essentially, it's involved in the licensing and activation of your Microsoft Office products. can be found under windows 7 ~ Vista, For older MSI version #> Function Init-SLC { $Method = [PSCustomObject]@{ attributes = [MethodAttributes]::Public -bor [MethodAttributes]::Static -bor [MethodAttributes]::PinvokeImpl CallingConventions = [CallingConventions]::Standard nativeCallConv = [CallingConvention]::Winapi nativeCharSet = [CharSet]::Unicode ImplAttributes = [MethodImplAttributes]::PreserveSig TypeAttributes = [TypeAttributes]::Public -bor [TypeAttributes]::Abstract -bor [TypeAttributes]::Sealed } $asm = [AppDomain]::CurrentDomain.DefineDynamicAssembly( (New-Object System.Reflection.AssemblyName "SLCAPI"), [System.Reflection.Emit.AssemblyBuilderAccess]::Run ) $mod = $asm.DefineDynamicModule("SLCAPIModule") $tb = $mod.DefineType("SLCMethods", $Method.TypeAttributes) $functions = @( @{ Name = "SLOpen"; Dll = "sppc.dll"; ReturnType = [int]; Parameters = [Type[]]@([IntPtr].MakeByRefType()) }, @{ Name = "SLGetLicense"; Dll = "sppc.dll"; ReturnType = [int]; Parameters = [Type[]]@( [IntPtr], # hSLC [Guid].MakeByRefType(), # pSkuId [UInt32].MakeByRefType(), # pBufferSize (pointer to UInt32) [IntPtr].MakeByRefType() # pBuffer (pointer to BYTE*) )}, @{ name = 'SLGetProductSkuInformation'; Dll = "sppc.dll"; returnType = [Int32]; parameters = @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()) }, @{ Name = "SLClose"; Dll = "sppc.dll"; ReturnType = [int]; Parameters = [Type[]]@([IntPtr]) }, @{ Name = "SLGetLicenseInformation"; Dll = "sppc.dll"; ReturnType = [int]; Parameters = [Type[]]@( [IntPtr], # hSLC [Guid].MakeByRefType(), # pSLLicenseId [string], # pwszValueName [IntPtr].MakeByRefType(), # peDataType (optional) [UInt32].MakeByRefType(), # pcbValue [IntPtr].MakeByRefType() # ppbValue )}, @{ Name = "SLGetPKeyInformation"; Dll = "sppc.dll"; ReturnType = [int]; Parameters = [Type[]]@( [IntPtr], # hSLC [Guid].MakeByRefType(), # pPKeyId [string], # pwszValueName [IntPtr].MakeByRefType(), # peDataType [UInt32].MakeByRefType(), # pcbValue [IntPtr].MakeByRefType() # ppbValue )}, @{ Name = 'SLGetInstalledProductKeyIds' Dll = "sppc.dll" ReturnType = [UInt32] Parameters = @( [IntPtr], # HSLC [Guid].MakeByRefType(), # pProductSkuId (nullable) [UInt32].MakeByRefType(), # *pnProductKeyIds [IntPtr].MakeByRefType() # **ppProductKeyIds ) }, @{ Name = 'SLGetApplicationInformation' Dll = "sppc.dll" ReturnType = [Int32] Parameters = @( [IntPtr], # HSLC hSLC [Guid].MakeByRefType(), # const SLID* pApplicationId [string], # PCWSTR pwszValueName [IntPtr], # SLDATATYPE* peDataType (optional) [IntPtr], # UINT* pcbValue (output) [IntPtr] # PBYTE* ppbValue (output pointer-to-pointer) ) }, @{ Name = 'SLGetGenuineInformation' Dll = "sppc.dll" ReturnType = [Int32] # HRESULT (return type of the function) Parameters = @( [Guid].MakeByRefType(), # const SLID* pQueryId [string], # PCWSTR pwszValueName [int].MakeByRefType(), # SLDATATYPE* peDataType (optional) [int].MakeByRefType(), # UINT* pcbValue (out) [IntPtr].MakeByRefType() # BYTE** ppbValue (out) ) }, @{ Name = 'SLGetSLIDList' Dll = "sppc.dll" ReturnType = [Int32] # HRESULT (return type of the function) Parameters = @( [IntPtr], # hSLC (HSLC handle) [Int32], # eQueryIdType (SLIDTYPE) [IntPtr], # null (no query ID passed) [Int32], # eReturnIdType (SLIDTYPE) [int].MakeByRefType(), [IntPtr].MakeByRefType() ) }, @{ Name = 'SLUninstallLicense' Dll = "sppc.dll" ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # hSLC [Guid].MakeByRefType() # const SLID* pLicenseFileId ) }, @{ Name = 'SLInstallLicense' Dll = "sppc.dll" ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # HSLC hSLC [UInt32], # UINT cbLicenseBlob [IntPtr], # const BYTE* pbLicenseBlob [Guid].MakeByRefType() # SLID* pLicenseFileId (output GUID) ) }, @{ Name = 'SLInstallProofOfPurchase' Dll = "sppc.dll" ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # HSLC hSLC [string], # pwszPKeyAlgorithm (e.g., "msft:rm/algorithm/pkey/2005") [string], # pwszPKeyString (the product key) [IntPtr], # cbPKeySpecificData (size of specific data, could be 0) [IntPtr], # pbPKeySpecificData (optional additional data, can be NULL) [Guid].MakeByRefType() # SLID* pPkeyId (output GUID) ) }, @{ Name = 'SLUninstallProofOfPurchase' Dll = "sppc.dll" ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # HSLC hSLC [Guid] # pPKeyId (the GUID returned from SLInstallProofOfPurchase) ) }, @{ Name = 'SLFireEvent' Dll = "sppc.dll" ReturnType = [Int32] # HRESULT (return type of the function) Parameters = @( [IntPtr], # hSLC [String], # pwszEventId (PCWSTR) [Guid].MakeByRefType() # pApplicationId (SLID*) ) }, @{ Name = 'SLReArm' Dll = 'sppc.dll' ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # hSLC (HSLC handle) [Guid].MakeByRefType(), # pApplicationId (const SLID* - pointer to GUID) [Guid].MakeByRefType(), # pProductSkuId (const SLID* - pointer to GUID, optional) [UInt32] # dwFlags (DWORD) ) }, @{ Name = 'SLReArmWindows' Dll = 'slc.dll' ReturnType = [Int32] # HRESULT Parameters = @() }, @{ Name = 'SLActivateProduct' Dll = 'slcext.dll' ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # hSLC (HSLC handle) [Guid].MakeByRefType(), # pProductSkuId (const SLID* - pointer to GUID) [UInt32], # cbAppSpecificData (UINT) [IntPtr], # pvAppSpecificData (const PVOID - pointer to arbitrary data, typically IntPtr.Zero if not used) [IntPtr], # pActivationInfo (const SL_ACTIVATION_INFO_HEADER* - pointer to structure, typically IntPtr.Zero if not used) [string], # pwszProxyServer (PCWSTR - string for proxy server, can be $null) [UInt16] # wProxyPort (WORD - unsigned 16-bit integer for proxy port) ) }, @{ Name = 'SLGetLicensingStatusInformation' Dll = 'sppc.dll' ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # hSLC (HSLC handle) [GUID].MakeByRefType(), # pAppID (const SLID * - pass [IntPtr]::Zero or allocated GUID) [GUID].MakeByRefType(), # pProductSkuId (const SLID * - pass [IntPtr]::Zero or allocated GUID) [IntPtr], # pwszRightName (PCWSTR - pass [IntPtr]::Zero for NULL) [uint32].MakeByRefType(), # pnStatusCount (UINT *) [IntPtr].MakeByRefType() # ppLicensingStatus (SL_LICENSING_STATUS **) ) }, @{ Name = 'SLConsumeWindowsRight' Dll = 'slc.dll' ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr] # hSLC (HSLC handle) ) }, @{ Name = 'SLConsumeRight' Dll = 'sppc.dll' ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # hSLC (HSLC handle) [GUID].MakeByRefType(), # pAppID (const SLID * - pass [IntPtr]::Zero or allocated GUID) [GUID].MakeByRefType(), # pProductSkuId (const SLID * - pass [IntPtr]::Zero or allocated GUID) [IntPtr], # pwszRightName (PCWSTR - pass [IntPtr]::Zero for NULL) [IntPtr] # pvReserved -> Null ) }, @{ Name = 'SLGetPKeyId' Dll = 'sppc.dll' ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # hSLC (HSLC handle) [string], # pwszPKeyAlgorithm [string], # pwszPKeyString [IntPtr], # cbPKeySpecificData -> NULL [IntPtr], # pbPKeySpecificData -> Null [GUID].MakeByRefType() # pPKeyId (const SLID * - pass [IntPtr]::Zero or allocated GUID) ) }, @{ Name = 'SLGenerateOfflineInstallationId' Dll = 'sppc.dll' ReturnType = [Int32] # HRESULT Parameters = @( [IntPtr], # hSLC (HSLC handle) [GUID].MakeByRefType(), # pProductSkuId (const SLID * - pass [IntPtr]::Zero or allocated GUID) [STRING].MakeByRefType() # [out] ppwszInstallationId ) } ) foreach ($f in $functions) { $tb.DefinePInvokeMethod($f.Name, $f.Dll, $Method.attributes, $Method.CallingConventions, $f.ReturnType, $f.Parameters, $Method.nativeCallConv, $Method.nativeCharSet ).SetImplementationFlags($Method.ImplAttributes) } return $tb.CreateType() } # INIT DLL Function $Global:SLC = Init-SLC $Global:ntdll = Init-NTDLL $Global:kernel32 = Init-KERNEL32 $Global:PebPtr = $Global:ntdll::RtlGetCurrentPeb() # Open-source slc.dll patch for Windows 8 Milestone builds (7850, 795x, 7989) # https://github.com/LBBNetwork/openredpill/blob/master/slpublic.h $slErrorBLock = @' 'SL_E_SRV_INVALID_PUBLISH_LICENSE' : (0xC004B001, 'The activation server determined that the license is invalid.'), 'SL_E_SRV_INVALID_PRODUCT_KEY_LICENSE' : (0xC004B002, 'The activation server determined that the license is invalid.'), 'SL_E_SRV_INVALID_RIGHTS_ACCOUNT_LICENSE' : (0xC004B003, 'The activation server determined that the license is invalid.'), 'SL_E_SRV_INVALID_LICENSE_STRUCTURE' : (0xC004B004, 'The activation server determined that the license is invalid.'), 'SL_E_SRV_AUTHORIZATION_FAILED' : (0xC004B005, 'The activation server determined that the license is invalid.'), 'SL_E_SRV_INVALID_BINDING' : (0xC004B006, 'The activation server determined that the license is invalid.'), 'SL_E_SRV_SERVER_PONG' : (0xC004B007, 'The activation server reported that the computer could not connect to the activation server.'), 'SL_E_SRV_INVALID_PAYLOAD' : (0xC004B008, 'The activation server determined that the product could not be activated.'), 'SL_E_SRV_INVALID_SECURITY_PROCESSOR_LICENSE' : (0xC004B009, 'The activation server determined that the license is invalid.'), 'SL_E_SRV_BUSINESS_TOKEN_ENTRY_NOT_FOUND' : (0xC004B010, 'The activation server determined that required business token entry cannot be found.'), 'SL_E_SRV_CLIENT_CLOCK_OUT_OF_SYNC' : (0xC004B011, 'The activation server determined that your computer clock time is not correct. You must correct your clock before you can activate.'), 'SL_E_SRV_GENERAL_ERROR' : (0xC004B100, 'The activation server determined that the product could not be activated.'), 'SL_E_CHPA_PRODUCT_KEY_OUT_OF_RANGE' : (0xC004C001, 'The activation server determined the specified product key is invalid.'), 'SL_E_CHPA_INVALID_BINDING' : (0xC004C002, 'The activation server determined there is a problem with the specified product key.'), 'SL_E_CHPA_PRODUCT_KEY_BLOCKED' : (0xC004C003, 'The activation server determined the specified product key has been blocked.'), 'SL_E_CHPA_INVALID_PRODUCT_KEY' : (0xC004C004, 'The activation server determined the specified product key is invalid.'), 'SL_E_CHPA_BINDING_NOT_FOUND' : (0xC004C005, 'The activation server determined the license is invalid.'), 'SL_E_CHPA_BINDING_MAPPING_NOT_FOUND' : (0xC004C006, 'The activation server determined the license is invalid.'), 'SL_E_CHPA_UNSUPPORTED_PRODUCT_KEY' : (0xC004C007, 'The activation server determined the specified product key is invalid.'), 'SL_E_CHPA_MAXIMUM_UNLOCK_EXCEEDED' : (0xC004C008, 'The activation server reported that the product key has exceeded its unlock limit.'), 'SL_E_CHPA_ACTCONFIG_ID_NOT_FOUND' : (0xC004C009, 'The activation server determined the license is invalid.'), 'SL_E_CHPA_INVALID_PRODUCT_DATA_ID' : (0xC004C00A, 'The activation server determined the license is invalid.'), 'SL_E_CHPA_INVALID_PRODUCT_DATA' : (0xC004C00B, 'The activation server determined the license is invalid.'), 'SL_E_CHPA_SYSTEM_ERROR' : (0xC004C00C, 'The activation server experienced an error.'), 'SL_E_CHPA_INVALID_ACTCONFIG_ID' : (0xC004C00D, 'The activation server determined the product key is not valid.'), 'SL_E_CHPA_INVALID_PRODUCT_KEY_LENGTH' : (0xC004C00E, 'The activation server determined the specified product key is invalid.'), 'SL_E_CHPA_INVALID_PRODUCT_KEY_FORMAT' : (0xC004C00F, 'The activation server determined the specified product key is invalid.'), 'SL_E_CHPA_INVALID_PRODUCT_KEY_CHAR' : (0xC004C010, 'The activation server determined the specified product key is invalid.'), 'SL_E_CHPA_INVALID_BINDING_URI' : (0xC004C011, 'The activation server determined the license is invalid.'), 'SL_E_CHPA_NETWORK_ERROR' : (0xC004C012, 'The activation server experienced a network error.'), 'SL_E_CHPA_DATABASE_ERROR' : (0xC004C013, 'The activation server experienced an error.'), 'SL_E_CHPA_INVALID_ARGUMENT' : (0xC004C014, 'The activation server experienced an error.'), 'SL_E_CHPA_RESPONSE_NOT_AVAILABLE' : (0xC004C015, 'The activation server experienced an error.'), 'SL_E_CHPA_OEM_SLP_COA0' : (0xC004C016, 'The activation server reported that the specified product key cannot be used for online activation.'), 'SL_E_CHPA_PRODUCT_KEY_BLOCKED_IPLOCATION' : (0xC004C017, 'The activation server determined the specified product key has been blocked for this geographic location.'), 'SL_E_CHPA_DMAK_LIMIT_EXCEEDED' : (0xC004C020, 'The activation server reported that the Multiple Activation Key has exceeded its limit.'), 'SL_E_CHPA_DMAK_EXTENSION_LIMIT_EXCEEDED' : (0xC004C021, 'The activation server reported that the Multiple Activation Key extension limit has been exceeded.'), 'SL_E_CHPA_REISSUANCE_LIMIT_NOT_FOUND' : (0xC004C022, 'The activation server reported that the re-issuance limit was not found.'), 'SL_E_CHPA_OVERRIDE_REQUEST_NOT_FOUND' : (0xC004C023, 'The activation server reported that the override request was not found.'), 'SL_E_CHPA_TIMEBASED_ACTIVATION_BEFORE_START_DATE' : (0xC004C030, 'The activation server reported that time based activation attempted before start date.'), 'SL_E_CHPA_TIMEBASED_ACTIVATION_AFTER_END_DATE' : (0xC004C031, 'The activation server reported that time based activation attempted after end date.'), 'SL_E_CHPA_TIMEBASED_ACTIVATION_NOT_AVAILABLE' : (0xC004C032, 'The activation server reported that new time based activation is not available.'), 'SL_E_CHPA_TIMEBASED_PRODUCT_KEY_NOT_CONFIGURED' : (0xC004C033, 'The activation server reported that the time based product key is not configured for activation.'), 'SL_E_CHPA_NO_RULES_TO_ACTIVATE' : (0xC004C04F, 'The activation server reported that no business rules available to activate specified product key.'), 'SL_E_CHPA_GENERAL_ERROR' : (0xC004C050, 'The activation server experienced a general error.'), 'SL_E_CHPA_DIGITALMARKER_INVALID_BINDING' : (0xC004C051, 'The activation server determined the license is invalid.'), 'SL_E_CHPA_DIGITALMARKER_BINDING_NOT_CONFIGURED' : (0xC004C052, 'The activation server determined there is a problem with the specified product key.'), 'SL_E_CHPA_DYNAMICALLY_BLOCKED_PRODUCT_KEY' : (0xC004C060, 'The activation server determined the specified product key has been blocked.'), 'SL_E_INVALID_LICENSE_STATE_BREACH_GRACE' : (0xC004C291, 'Genuine Validation determined the license state is invalid.'), 'SL_E_INVALID_LICENSE_STATE_BREACH_GRACE_EXPIRED' : (0xC004C292, 'Genuine Validation determined the license state is invalid.'), 'SL_E_INVALID_TEMPLATE_ID' : (0xC004C2F6, 'Genuine Validation determined the validation input template identifier is invalid.'), 'SL_E_INVALID_XML_BLOB' : (0xC004C2FA, 'Genuine Validation determined the validation input data blob is invalid.'), 'SL_E_VALIDATION_BLOB_PARAM_NOT_FOUND' : (0xC004C327, 'Genuine Validation determined the validation input data blob parameter is invalid.'), 'SL_E_INVALID_CLIENT_TOKEN' : (0xC004C328, 'Genuine Validation determined the client token data is invalid.'), 'SL_E_INVALID_OFFLINE_BLOB' : (0xC004C329, 'Genuine Validation determined the offline data blob is invalid.'), 'SL_E_OFFLINE_VALIDATION_BLOB_PARAM_NOT_FOUND' : (0xC004C32A, 'Genuine Validation determined the offline data blob parameter is invalid.'), 'SL_E_INVALID_OSVERSION_TEMPLATEID' : (0xC004C32B, 'Genuine Validation determined the validation template identifier is invalid for this version of the Windows operating system.'), 'SL_E_OFFLINE_GENUINE_BLOB_REVOKED' : (0xC004C32C, 'Genuine Validation determined the offline genuine blob is revoked.'), 'SL_E_OFFLINE_GENUINE_BLOB_NOT_FOUND' : (0xC004C32D, 'Genuine Validation determined the offline genuine blob is not found.'), 'SL_E_CHPA_MSCH_RESPONSE_NOT_AVAILABLE_VGA' : (0xC004C3FF, 'The activation server determined the VGA service response is not available in the expected format.'), 'SL_E_INVALID_OS_FOR_PRODUCT_KEY' : (0xC004C401, 'Genuine Validation determined the product key is invalid for this version of the Windows operating system.'), 'SL_E_INVALID_FILE_HASH' : (0xC004C4A1, 'Genuine Validation determined the file hash is invalid.'), 'SL_E_VALIDATION_BLOCKED_PRODUCT_KEY' : (0xC004C4A2, 'Genuine Validation determined the product key has been blocked.'), 'SL_E_MISMATCHED_KEY_TYPES' : (0xC004C4A4, 'Genuine Validation determined the product key type is invalid.'), 'SL_E_VALIDATION_INVALID_PRODUCT_KEY' : (0xC004C4A5, 'Genuine Validation determined the product key is invalid.'), 'SL_E_INVALID_OEM_OR_VOLUME_BINDING_DATA' : (0xC004C4A7, 'Genuine Validation determined the OEM or Volume binding data is invalid.'), 'SL_E_INVALID_LICENSE_STATE' : (0xC004C4A8, 'Genuine Validation determined the license state is invalid.'), 'SL_E_IP_LOCATION_FALIED' : (0xC004C4A9, 'Genuine Validation determined the specified product key has been blocked for this geographic location.'), 'SL_E_SOFTMOD_EXPLOIT_DETECTED' : (0xC004C4AB, 'Genuine Validation detected Windows licensing exploits.'), 'SL_E_INVALID_TOKEN_DATA' : (0xC004C4AC, 'Genuine Validation determined the token activation data is invalid.'), 'SL_E_HEALTH_CHECK_FAILED_NEUTRAL_FILES' : (0xC004C4AD, 'Genuine Validation detected tampered Windows binaries.'), 'SL_E_HEALTH_CHECK_FAILED_MUI_FILES' : (0xC004C4AE, 'Genuine Validation detected tampered Windows binaries.'), 'SL_E_INVALID_AD_DATA' : (0xC004C4AF, 'Genuine Validation determined the active directory activation data is invalid.'), 'SL_E_INVALID_RSDP_COUNT' : (0xC004C4B0, 'Genuine Validation detected Windows licensing exploits.'), 'SL_E_ENGINE_DETECTED_EXPLOIT' : (0xC004C4B1, 'Genuine Validation detected Windows licensing exploits.'), 'SL_E_NOTIFICATION_BREACH_DETECTED' : (0xC004C531, 'Genuine Validation detected Windows licensing exploits.'), 'SL_E_NOTIFICATION_GRACE_EXPIRED' : (0xC004C532, 'Genuine Validation determined the license state is in notification due to expired grace.'), 'SL_E_NOTIFICATION_OTHER_REASONS' : (0xC004C533, 'Genuine Validation determined the license state is in notification.'), 'SL_E_NON_GENUINE_STATUS_LAST' : (0xC004C600, 'Genuine Validation determined your copy of Windows is not genuine.'), 'SL_E_CHPA_BUSINESS_RULE_INPUT_NOT_FOUND' : (0xC004C700, 'The activation server reported that business rule cound not find required input.'), 'SL_E_CHPA_NULL_VALUE_FOR_PROPERTY_NAME_OR_ID' : (0xC004C750, 'The activation server reported that NULL value specified for business property name and Id.'), 'SL_E_CHPA_UNKNOWN_PROPERTY_NAME' : (0xC004C751, 'The activation server reported that property name specifies unknown property.'), 'SL_E_CHPA_UNKNOWN_PROPERTY_ID' : (0xC004C752, 'The activation server reported that property Id specifies unknown property.'), 'SL_E_CHPA_FAILED_TO_UPDATE_PRODUCTKEY_BINDING' : (0xC004C755, 'The activation server reported that it failed to update product key binding.'), 'SL_E_CHPA_FAILED_TO_INSERT_PRODUCTKEY_BINDING' : (0xC004C756, 'The activation server reported that it failed to insert product key binding.'), 'SL_E_CHPA_FAILED_TO_DELETE_PRODUCTKEY_BINDING' : (0xC004C757, 'The activation server reported that it failed to delete product key binding.'), 'SL_E_CHPA_FAILED_TO_PROCESS_PRODUCT_KEY_BINDINGS_XML' : (0xC004C758, 'The activation server reported that it failed to process input XML for product key bindings.'), 'SL_E_CHPA_FAILED_TO_INSERT_PRODUCT_KEY_PROPERTY' : (0xC004C75A, 'The activation server reported that it failed to insert product key property.'), 'SL_E_CHPA_FAILED_TO_UPDATE_PRODUCT_KEY_PROPERTY' : (0xC004C75B, 'The activation server reported that it failed to update product key property.'), 'SL_E_CHPA_FAILED_TO_DELETE_PRODUCT_KEY_PROPERTY' : (0xC004C75C, 'The activation server reported that it failed to delete product key property.'), 'SL_E_CHPA_UNKNOWN_PRODUCT_KEY_TYPE' : (0xC004C764, 'The activation server reported that the product key type is unknown.'), 'SL_E_CHPA_PRODUCT_KEY_BEING_USED' : (0xC004C770, 'The activation server reported that the product key type is being used by another user.'), 'SL_E_CHPA_FAILED_TO_INSERT_PRODUCT_KEY_RECORD' : (0xC004C780, 'The activation server reported that it failed to insert product key record.'), 'SL_E_CHPA_FAILED_TO_UPDATE_PRODUCT_KEY_RECORD' : (0xC004C781, 'The activation server reported that it failed to update product key record.'), 'SL_REMAPPING_SP_PUB_API_INVALID_LICENSE' : (0xC004D000, ''), 'SL_REMAPPING_SP_PUB_API_INVALID_ALGORITHM_TYPE' : (0xC004D009, ''), 'SL_REMAPPING_SP_PUB_API_TOO_MANY_LOADED_ENVIRONMENTS' : (0xC004D00C, ''), 'SL_REMAPPING_SP_PUB_API_BAD_GET_INFO_QUERY' : (0xC004D012, ''), 'SL_REMAPPING_SP_PUB_API_INVALID_KEY_LENGTH' : (0xC004D055, ''), 'SL_REMAPPING_SP_PUB_API_NO_AES_PROVIDER' : (0xC004D073, ''), 'SL_REMAPPING_SP_PUB_API_HANDLE_NOT_COMMITED' : (0xC004D081, 'The handle was used before calling SPCommit with it.'), 'SL_REMAPPING_SP_PUB_GENERAL_NOT_INITIALIZED' : (0xC004D101, 'The security processor reported an initialization error.'), 'SL_REMAPPING_SP_STATUS_SYSTEM_TIME_SKEWED' : (0x8004D102, 'The security processor reported that the machine time is inconsistent with the trusted time.'), 'SL_REMAPPING_SP_STATUS_GENERIC_FAILURE' : (0xC004D103, 'The security processor reported that an error has occurred.'), 'SL_REMAPPING_SP_STATUS_INVALIDARG' : (0xC004D104, 'The security processor reported that invalid data was used.'), 'SL_REMAPPING_SP_STATUS_ALREADY_EXISTS' : (0xC004D105, 'The security processor reported that the value already exists.'), 'SL_REMAPPING_SP_STATUS_INSUFFICIENT_BUFFER' : (0xC004D107, 'The security processor reported that an insufficient buffer was used.'), 'SL_REMAPPING_SP_STATUS_INVALIDDATA' : (0xC004D108, 'The security processor reported that invalid data was used.'), 'SL_REMAPPING_SP_STATUS_INVALID_SPAPI_CALL' : (0xC004D109, 'The security processor reported that an invalid call was made.'), 'SL_REMAPPING_SP_STATUS_INVALID_SPAPI_VERSION' : (0xC004D10A, 'The security processor reported a version mismatch error.'), 'SL_REMAPPING_SP_STATUS_DEBUGGER_DETECTED' : (0x8004D10B, 'The security processor cannot operate while a debugger is attached.'), 'SL_REMAPPING_SP_STATUS_NO_MORE_DATA' : (0xC004D10C, 'No more data is available.'), 'SL_REMAPPING_SP_PUB_CRYPTO_INVALID_KEYLENGTH' : (0xC004D201, 'The length of the cryptopgraphic key material/blob is invalid.'), 'SL_REMAPPING_SP_PUB_CRYPTO_INVALID_BLOCKLENGTH' : (0xC004D202, 'The block length is not correct for this algorithm.'), 'SL_REMAPPING_SP_PUB_CRYPTO_INVALID_CIPHER' : (0xC004D203, 'The Cryptopgrahic cipher/algorithm type is invalid.'), 'SL_REMAPPING_SP_PUB_CRYPTO_INVALID_CIPHERMODE' : (0xC004D204, 'The specified cipher mode is invalid. For example both encrypt and decrypt cannot be specified for symmetric keys.'), 'SL_REMAPPING_SP_PUB_CRYPTO_UNKNOWN_PROVIDERID' : (0xC004D205, 'The SPAPIID for the specified Cryptographic Provider is unknown.'), 'SL_REMAPPING_SP_PUB_CRYPTO_UNKNOWN_KEYID' : (0xC004D206, 'The SPAPIID for the specified Cryptographic Key (type) is unknown.'), 'SL_REMAPPING_SP_PUB_CRYPTO_UNKNOWN_HASHID' : (0xC004D207, 'The SPAPIID for the specified Cryptographic Hash is unknown.'), 'SL_REMAPPING_SP_PUB_CRYPTO_UNKNOWN_ATTRIBUTEID' : (0xC004D208, 'The SPAPIID for the specified Cryptographic Attribute is unknown.'), 'SL_REMAPPING_SP_PUB_CRYPTO_HASH_FINALIZED' : (0xC004D209, 'The hash object has been finalized and can no longer be updated.'), 'SL_REMAPPING_SP_PUB_CRYPTO_KEY_NOT_AVAILABLE' : (0xC004D20A, 'The key is not available within the current state.'), 'SL_REMAPPING_SP_PUB_CRYPTO_KEY_NOT_FOUND' : (0xC004D20B, 'The key does not exist. It may not have have been created yet.'), 'SL_REMAPPING_SP_PUB_CRYPTO_NOT_BLOCK_ALIGNED' : (0xC004D20C, "The data length is not a multiple of the algorithm's block length."), 'SL_REMAPPING_SP_PUB_CRYPTO_INVALID_SIGNATURELENGTH' : (0xC004D20D, 'The length of the signature is not valid.'), 'SL_REMAPPING_SP_PUB_CRYPTO_INVALID_SIGNATURE' : (0xC004D20E, 'The signature does not correlate with the comparison hash.'), 'SL_REMAPPING_SP_PUB_CRYPTO_INVALID_BLOCK' : (0xC004D20F, 'The RSA block is not valid.'), 'SL_REMAPPING_SP_PUB_CRYPTO_INVALID_FORMAT' : (0xC004D210, 'The format of the RSA block is not valid.'), 'SL_REMAPPING_SP_PUB_CRYPTO_INVALID_PADDING' : (0xC004D211, 'The CBC padding is not valid.'), 'SL_REMAPPING_SP_PUB_TS_TAMPERED' : (0xC004D301, 'The security processor reported that the trusted data store was tampered.'), 'SL_REMAPPING_SP_PUB_TS_REARMED' : (0xC004D302, 'The security processor reported that the trusted data store was rearmed.'), 'SL_REMAPPING_SP_PUB_TS_RECREATED' : (0xC004D303, 'The security processor reported that the trusted store has been recreated.'), 'SL_REMAPPING_SP_PUB_TS_ENTRY_KEY_NOT_FOUND' : (0xC004D304, 'The security processor reported that entry key was not found in the trusted data store.'), 'SL_REMAPPING_SP_PUB_TS_ENTRY_KEY_ALREADY_EXISTS' : (0xC004D305, 'The security processor reported that the entry key already exists in the trusted data store.'), 'SL_REMAPPING_SP_PUB_TS_ENTRY_KEY_SIZE_TOO_BIG' : (0xC004D306, 'The security processor reported that the entry key is too big to fit in the trusted data store.'), 'SL_REMAPPING_SP_PUB_TS_MAX_REARM_REACHED' : (0xC004D307, 'The security processor reported that the maximum allowed number of re-arms has been exceeded. You must re-install the OS before trying to re-arm again.'), 'SL_REMAPPING_SP_PUB_TS_DATA_SIZE_TOO_BIG' : (0xC004D308, 'The security processor has reported that entry data size is too big to fit in the trusted data store.'), 'SL_REMAPPING_SP_PUB_TS_INVALID_HW_BINDING' : (0xC004D309, 'The security processor has reported that the machine has gone out of hardware tolerance.'), 'SL_REMAPPING_SP_PUB_TIMER_ALREADY_EXISTS' : (0xC004D30A, 'The security processor has reported that the secure timer already exists.'), 'SL_REMAPPING_SP_PUB_TIMER_NOT_FOUND' : (0xC004D30B, 'The security processor has reported that the secure timer was not found.'), 'SL_REMAPPING_SP_PUB_TIMER_EXPIRED' : (0xC004D30C, 'The security processor has reported that the secure timer has expired.'), 'SL_REMAPPING_SP_PUB_TIMER_NAME_SIZE_TOO_BIG' : (0xC004D30D, 'The security processor has reported that the secure timer name is too long.'), 'SL_REMAPPING_SP_PUB_TS_FULL' : (0xC004D30E, 'The security processor reported that the trusted data store is full.'), 'SL_REMAPPING_SP_PUB_TRUSTED_TIME_OK' : (0x4004D30F, 'Trusted time is already up-to-date.'), 'SL_REMAPPING_SP_PUB_TS_ENTRY_READ_ONLY' : (0xC004D310, 'Read-only entry cannot be modified.'), 'SL_REMAPPING_SP_PUB_TIMER_READ_ONLY' : (0xC004D311, 'Read-only timer cannot be modified.'), 'SL_REMAPPING_SP_PUB_TS_ATTRIBUTE_READ_ONLY' : (0xC004D312, 'Read-only attribute cannot be modified.'), 'SL_REMAPPING_SP_PUB_TS_ATTRIBUTE_NOT_FOUND' : (0xC004D313, 'Attribute not found.'), 'SL_REMAPPING_SP_PUB_TS_ACCESS_DENIED' : (0xC004D314, 'Trusted Store access denied.'), 'SL_REMAPPING_SP_PUB_TS_NAMESPACE_NOT_FOUND' : (0xC004D315, 'Namespace not found.'), 'SL_REMAPPING_SP_PUB_TS_NAMESPACE_IN_USE' : (0xC004D316, 'Namespace in use.'), 'SL_REMAPPING_SP_PUB_TS_TAMPERED_BREADCRUMB_LOAD_INVALID' : (0xC004D317, 'Trusted store tampered.'), 'SL_REMAPPING_SP_PUB_TS_TAMPERED_BREADCRUMB_GENERATION' : (0xC004D318, 'Trusted store tampered.'), 'SL_REMAPPING_SP_PUB_TS_TAMPERED_INVALID_DATA' : (0xC004D319, 'Trusted store tampered.'), 'SL_REMAPPING_SP_PUB_TS_TAMPERED_NO_DATA' : (0xC004D31A, 'Trusted store tampered.'), 'SL_REMAPPING_SP_PUB_TS_TAMPERED_DATA_BREADCRUMB_MISMATCH' : (0xC004D31B, 'Trusted store tampered'), 'SL_REMAPPING_SP_PUB_TS_TAMPERED_DATA_VERSION_MISMATCH' : (0xC004D31C, 'Trusted store tampered.'), 'SL_REMAPPING_SP_PUB_TAMPER_MODULE_AUTHENTICATION' : (0xC004D401, 'The security processor reported a system file mismatch error.'), 'SL_REMAPPING_SP_PUB_TAMPER_SECURITY_PROCESSOR_PATCHED' : (0xC004D402, 'The security processor reported a system file mismatch error.'), 'SL_REMAPPING_SP_PUB_KM_CACHE_TAMPER' : (0xC004D501, 'The security processor reported an error with the kernel data.'), 'SL_REMAPPING_SP_PUB_KM_CACHE_TAMPER_RESTORE_FAILED' : (0xC004D502, 'Kernel Mode Cache is tampered and the restore attempt failed.'), 'SL_REMAPPING_SP_PUB_KM_CACHE_IDENTICAL' : (0x4004D601, 'Kernel Mode Cache was not changed.'), 'SL_REMAPPING_SP_PUB_KM_CACHE_POLICY_CHANGED' : (0x4004D602, 'Reboot-requiring policies have changed.'), 'SL_REMAPPING_SP_STATUS_PUSHKEY_CONFLICT' : (0xC004D701, 'External decryption key was already set for specified feature.'), 'SL_REMAPPING_SP_PUB_PROXY_SOFT_TAMPER' : (0xC004D702, 'Error occured during proxy execution'), 'SL_E_INVALID_CONTEXT' : (0xC004E001, 'The Software Licensing Service determined that the specified context is invalid.'), 'SL_E_TOKEN_STORE_INVALID_STATE' : (0xC004E002, 'The Software Licensing Service reported that the license store contains inconsistent data.'), 'SL_E_EVALUATION_FAILED' : (0xC004E003, 'The Software Licensing Service reported that license evaluation failed.'), 'SL_E_NOT_EVALUATED' : (0xC004E004, 'The Software Licensing Service reported that the license has not been evaluated.'), 'SL_E_NOT_ACTIVATED' : (0xC004E005, 'The Software Licensing Service reported that the license is not activated.'), 'SL_E_INVALID_GUID' : (0xC004E006, 'The Software Licensing Service reported that the license contains invalid data.'), 'SL_E_TOKSTO_TOKEN_NOT_FOUND' : (0xC004E007, 'The Software Licensing Service reported that the license store does not contain the requested license.'), 'SL_E_TOKSTO_NO_PROPERTIES' : (0xC004E008, 'The Software Licensing Service reported that the license property is invalid.'), 'SL_E_TOKSTO_NOT_INITIALIZED' : (0xC004E009, 'The Software Licensing Service reported that the license store is not initialized.'), 'SL_E_TOKSTO_ALREADY_INITIALIZED' : (0xC004E00A, 'The Software Licensing Service reported that the license store is already initialized.'), 'SL_E_TOKSTO_NO_ID_SET' : (0xC004E00B, 'The Software Licensing Service reported that the license property is invalid.'), 'SL_E_TOKSTO_CANT_CREATE_FILE' : (0xC004E00C, 'The Software Licensing Service reported that the license could not be opened or created.'), 'SL_E_TOKSTO_CANT_WRITE_TO_FILE' : (0xC004E00D, 'The Software Licensing Service reported that the license could not be written.'), 'SL_E_TOKSTO_CANT_READ_FILE' : (0xC004E00E, 'The Software Licensing Service reported that the license store could not read the license file.'), 'SL_E_TOKSTO_CANT_PARSE_PROPERTIES' : (0xC004E00F, 'The Software Licensing Service reported that the license property is corrupted.'), 'SL_E_TOKSTO_PROPERTY_NOT_FOUND' : (0xC004E010, 'The Software Licensing Service reported that the license property is missing.'), 'SL_E_TOKSTO_INVALID_FILE' : (0xC004E011, 'The Software Licensing Service reported that the license store contains an invalid license file.'), 'SL_E_TOKSTO_CANT_CREATE_MUTEX' : (0xC004E012, 'The Software Licensing Service reported that the license store failed to start synchronization properly.'), 'SL_E_TOKSTO_CANT_ACQUIRE_MUTEX' : (0xC004E013, 'The Software Licensing Service reported that the license store failed to synchronize properly.'), 'SL_E_TOKSTO_NO_TOKEN_DATA' : (0xC004E014, 'The Software Licensing Service reported that the license property is invalid.'), 'SL_E_EUL_CONSUMPTION_FAILED' : (0xC004E015, 'The Software Licensing Service reported that license consumption failed.'), 'SL_E_PKEY_INVALID_CONFIG' : (0xC004E016, 'The Software Licensing Service reported that the product key is invalid.'), 'SL_E_PKEY_INVALID_UNIQUEID' : (0xC004E017, 'The Software Licensing Service reported that the product key is invalid.'), 'SL_E_PKEY_INVALID_ALGORITHM' : (0xC004E018, 'The Software Licensing Service reported that the product key is invalid.'), 'SL_E_PKEY_INTERNAL_ERROR' : (0xC004E019, 'The Software Licensing Service determined that validation of the specified product key failed.'), 'SL_E_LICENSE_INVALID_ADDON_INFO' : (0xC004E01A, 'The Software Licensing Service reported that invalid add-on information was found.'), 'SL_E_HWID_ERROR' : (0xC004E01B, 'The Software Licensing Service reported that not all hardware information could be collected.'), 'SL_E_PKEY_INVALID_KEYCHANGE1' : (0xC004E01C, 'This evaluation product key is no longer valid.'), 'SL_E_PKEY_INVALID_KEYCHANGE2' : (0xC004E01D, 'The new product key cannot be used on this installation of Windows. Type a different product key. (CD-AB)'), 'SL_E_PKEY_INVALID_KEYCHANGE3' : (0xC004E01E, 'The new product key cannot be used on this installation of Windows. Type a different product key. (AB-AB)'), 'SL_E_POLICY_OTHERINFO_MISMATCH' : (0xC004E020, 'The Software Licensing Service reported that there is a mismatched between a policy value and information stored in the OtherInfo section.'), 'SL_E_PRODUCT_UNIQUENESS_GROUP_ID_INVALID' : (0xC004E021, 'The Software Licensing Service reported that the Genuine information contained in the license is not consistent.'), 'SL_E_SECURE_STORE_ID_MISMATCH' : (0xC004E022, 'The Software Licensing Service reported that the secure store id value in license does not match with the current value.'), 'SL_E_INVALID_RULESET_RULE' : (0xC004E023, 'The Software Licensing Service reported that the notification rules appear to be invalid.'), 'SL_E_INVALID_CONTEXT_DATA' : (0xC004E024, 'The Software Licensing Service reported that the reported machine data appears to be invalid.'), 'SL_E_INVALID_HASH' : (0xC004E025, 'The Software Licensing Service reported that the data hash does not correspond to the data.'), 'SL_E_INVALID_USE_OF_ADD_ON_PKEY' : (0x8004E026, 'The Software Licensing Service reported that a valid product key for an add-on sku was entered where a Windows product key was expected.'), 'SL_E_WINDOWS_VERSION_MISMATCH' : (0xC004E027, 'The Software Licensing Service reported that the version of SPPSvc does not match the policy.'), 'SL_E_ACTIVATION_IN_PROGRESS' : (0xC004E028, 'The Software Licensing Service reported that there is another activation attempt in progress for this sku. Please wait for that attempt to complete before trying again.'), 'SL_E_STORE_UPGRADE_TOKEN_REQUIRED' : (0xC004E029, 'The Software Licensing Service reported that the activated license requires a corresponding Store upgrade license in order to work. Please visit the Store to purchase a new license or re-download an existing one.'), 'SL_E_STORE_UPGRADE_TOKEN_WRONG_EDITION' : (0xC004E02A, 'The Software Licensing Service reported that the Store upgrade license is not enabled for the current OS edition. Please visit the Store to purchase the appropriate license.'), 'SL_E_STORE_UPGRADE_TOKEN_WRONG_PID' : (0xC004E02B, 'The Software Licensing Service reported that the Store upgrade license does not match the current active product key. Please visit the Store to purchase a new license or re-download an existing one.'), 'SL_E_STORE_UPGRADE_TOKEN_NOT_PRS_SIGNED' : (0xC004E02C, 'The Software Licensing Service reported that the Store upgrade license does not match the current signing level for the installed Operating System. Please visit the Store to purchase a new license or re-download an existing one.'), 'SL_E_STORE_UPGRADE_TOKEN_WRONG_VERSION' : (0xC004E02D, 'The Software Licensing Service reported that the Store upgrade license does not enable the current version of the installed Operating System. Please visit the Store to purchase a new license or re-download an existing one.'), 'SL_E_STORE_UPGRADE_TOKEN_NOT_AUTHORIZED' : (0xC004E02E, 'The Software Licensing Service reported that the Store upgrade license could not be authorized. Please visit the Store to purchase a new license or re-download an existing one.'), 'SL_E_SFS_INVALID_FS_VERSION' : (0x8004E101, 'The Software Licensing Service reported that the Token Store file version is invalid.'), 'SL_E_SFS_INVALID_FD_TABLE' : (0x8004E102, 'The Software Licensing Service reported that the Token Store contains an invalid descriptor table.'), 'SL_E_SFS_INVALID_SYNC' : (0x8004E103, 'The Software Licensing Service reported that the Token Store contains a token with an invalid header/footer.'), 'SL_E_SFS_BAD_TOKEN_NAME' : (0x8004E104, 'The Software Licensing Service reported that a Token Store token has an invalid name.'), 'SL_E_SFS_BAD_TOKEN_EXT' : (0x8004E105, 'The Software Licensing Service reported that a Token Store token has an invalid extension.'), 'SL_E_SFS_DUPLICATE_TOKEN_NAME' : (0x8004E106, 'The Software Licensing Service reported that the Token Store contains a duplicate token.'), 'SL_E_SFS_TOKEN_SIZE_MISMATCH' : (0x8004E107, 'The Software Licensing Service reported that a token in the Token Store has a size mismatch.'), 'SL_E_SFS_INVALID_TOKEN_DATA_HASH' : (0x8004E108, 'The Software Licensing Service reported that a token in the Token Store contains an invalid hash.'), 'SL_E_SFS_FILE_READ_ERROR' : (0x8004E109, 'The Software Licensing Service reported that the Token Store was unable to read a token.'), 'SL_E_SFS_FILE_WRITE_ERROR' : (0x8004E10A, 'The Software Licensing Service reported that the Token Store was unable to write a token.'), 'SL_E_SFS_INVALID_FILE_POSITION' : (0x8004E10B, 'The Software Licensing Service reported that the Token Store attempted an invalid file operation.'), 'SL_E_SFS_NO_ACTIVE_TRANSACTION' : (0x8004E10C, 'The Software Licensing Service reported that there is no active transaction.'), 'SL_E_SFS_INVALID_FS_HEADER' : (0x8004E10D, 'The Software Licensing Service reported that the Token Store file header is invalid.'), 'SL_E_SFS_INVALID_TOKEN_DESCRIPTOR' : (0x8004E10E, 'The Software Licensing Service reported that a Token Store token descriptor is invalid.'), 'SL_E_INTERNAL_ERROR' : (0xC004F001, 'The Software Licensing Service reported an internal error.'), 'SL_E_RIGHT_NOT_CONSUMED' : (0xC004F002, 'The Software Licensing Service reported that rights consumption failed.'), 'SL_E_USE_LICENSE_NOT_INSTALLED' : (0xC004F003, 'The Software Licensing Service reported that the required license could not be found.'), 'SL_E_MISMATCHED_PKEY_RANGE' : (0xC004F004, 'The Software Licensing Service reported that the product key does not match the range defined in the license.'), 'SL_E_MISMATCHED_PID' : (0xC004F005, 'The Software Licensing Service reported that the product key does not match the product key for the license.'), 'SL_E_EXTERNAL_SIGNATURE_NOT_FOUND' : (0xC004F006, 'The Software Licensing Service reported that the signature file for the license is not available.'), 'SL_E_RAC_NOT_AVAILABLE' : (0xC004F007, 'The Software Licensing Service reported that the license could not be found.'), 'SL_E_SPC_NOT_AVAILABLE' : (0xC004F008, 'The Software Licensing Service reported that the license could not be found.'), 'SL_E_GRACE_TIME_EXPIRED' : (0xC004F009, 'The Software Licensing Service reported that the grace period expired.'), 'SL_E_MISMATCHED_APPID' : (0xC004F00A, 'The Software Licensing Service reported that the application ID does not match the application ID for the license.'), 'SL_E_NO_PID_CONFIG_DATA' : (0xC004F00B, 'The Software Licensing Service reported that the product identification data is not available.'), 'SL_I_OOB_GRACE_PERIOD' : (0x4004F00C, 'The Software Licensing Service reported that the application is running within the valid grace period.'), 'SL_I_OOT_GRACE_PERIOD' : (0x4004F00D, 'The Software Licensing Service reported that the application is running within the valid out of tolerance grace period.'), 'SL_E_MISMATCHED_SECURITY_PROCESSOR' : (0xC004F00E, 'The Software Licensing Service determined that the license could not be used by the current version of the security processor component.'), 'SL_E_OUT_OF_TOLERANCE' : (0xC004F00F, 'The Software Licensing Service reported that the hardware ID binding is beyond the level of tolerance.'), 'SL_E_INVALID_PKEY' : (0xC004F010, 'The Software Licensing Service reported that the product key is invalid.'), 'SL_E_LICENSE_FILE_NOT_INSTALLED' : (0xC004F011, 'The Software Licensing Service reported that the license file is not installed.'), 'SL_E_VALUE_NOT_FOUND' : (0xC004F012, 'The Software Licensing Service reported that the call has failed because the value for the input key was not found.'), 'SL_E_RIGHT_NOT_GRANTED' : (0xC004F013, 'The Software Licensing Service determined that there is no permission to run the software.'), 'SL_E_PKEY_NOT_INSTALLED' : (0xC004F014, 'The Software Licensing Service reported that the product key is not available.'), 'SL_E_PRODUCT_SKU_NOT_INSTALLED' : (0xC004F015, 'The Software Licensing Service reported that the license is not installed.'), 'SL_E_NOT_SUPPORTED' : (0xC004F016, 'The Software Licensing Service determined that the request is not supported.'), 'SL_E_PUBLISHING_LICENSE_NOT_INSTALLED' : (0xC004F017, 'The Software Licensing Service reported that the license is not installed.'), 'SL_E_LICENSE_SERVER_URL_NOT_FOUND' : (0xC004F018, 'The Software Licensing Service reported that the license does not contain valid location data for the activation server.'), 'SL_E_INVALID_EVENT_ID' : (0xC004F019, 'The Software Licensing Service determined that the requested event ID is invalid.'), 'SL_E_EVENT_NOT_REGISTERED' : (0xC004F01A, 'The Software Licensing Service determined that the requested event is not registered with the service.'), 'SL_E_EVENT_ALREADY_REGISTERED' : (0xC004F01B, 'The Software Licensing Service reported that the event ID is already registered.'), 'SL_E_DECRYPTION_LICENSES_NOT_AVAILABLE' : (0xC004F01C, 'The Software Licensing Service reported that the license is not installed.'), 'SL_E_LICENSE_SIGNATURE_VERIFICATION_FAILED' : (0xC004F01D, 'The Software Licensing Service reported that the verification of the license failed.'), 'SL_E_DATATYPE_MISMATCHED' : (0xC004F01E, 'The Software Licensing Service determined that the input data type does not match the data type in the license.'), 'SL_E_INVALID_LICENSE' : (0xC004F01F, 'The Software Licensing Service determined that the license is invalid.'), 'SL_E_INVALID_PACKAGE' : (0xC004F020, 'The Software Licensing Service determined that the license package is invalid.'), 'SL_E_VALIDITY_TIME_EXPIRED' : (0xC004F021, 'The Software Licensing Service reported that the validity period of the license has expired.'), 'SL_E_LICENSE_AUTHORIZATION_FAILED' : (0xC004F022, 'The Software Licensing Service reported that the license authorization failed.'), 'SL_E_LICENSE_DECRYPTION_FAILED' : (0xC004F023, 'The Software Licensing Service reported that the license is invalid.'), 'SL_E_WINDOWS_INVALID_LICENSE_STATE' : (0xC004F024, 'The Software Licensing Service reported that the license is invalid.'), 'SL_E_LUA_ACCESSDENIED' : (0xC004F025, 'The Software Licensing Service reported that the action requires administrator privilege.'), 'SL_E_PROXY_KEY_NOT_FOUND' : (0xC004F026, 'The Software Licensing Service reported that the required data is not found.'), 'SL_E_TAMPER_DETECTED' : (0xC004F027, 'The Software Licensing Service reported that the license is tampered.'), 'SL_E_POLICY_CACHE_INVALID' : (0xC004F028, 'The Software Licensing Service reported that the policy cache is invalid.'), 'SL_E_INVALID_RUNNING_MODE' : (0xC004F029, 'The Software Licensing Service cannot be started in the current OS mode.'), 'SL_E_SLP_NOT_SIGNED' : (0xC004F02A, 'The Software Licensing Service reported that the license is invalid.'), 'SL_E_CIDIID_INVALID_DATA' : (0xC004F02C, 'The Software Licensing Service reported that the format for the offline activation data is incorrect.'), 'SL_E_CIDIID_INVALID_VERSION' : (0xC004F02D, 'The Software Licensing Service determined that the version of the offline Confirmation ID (CID) is incorrect.'), 'SL_E_CIDIID_VERSION_NOT_SUPPORTED' : (0xC004F02E, 'The Software Licensing Service determined that the version of the offline Confirmation ID (CID) is not supported.'), 'SL_E_CIDIID_INVALID_DATA_LENGTH' : (0xC004F02F, 'The Software Licensing Service reported that the length of the offline Confirmation ID (CID) is incorrect.'), 'SL_E_CIDIID_NOT_DEPOSITED' : (0xC004F030, 'The Software Licensing Service determined that the Installation ID (IID) or the Confirmation ID (CID) could not been saved.'), 'SL_E_CIDIID_MISMATCHED' : (0xC004F031, 'The Installation ID (IID) and the Confirmation ID (CID) do not match. Please confirm the IID and reacquire a new CID if necessary.'), 'SL_E_INVALID_BINDING_BLOB' : (0xC004F032, 'The Software Licensing Service determined that the binding data is invalid.'), 'SL_E_PRODUCT_KEY_INSTALLATION_NOT_ALLOWED' : (0xC004F033, 'The Software Licensing Service reported that the product key is not allowed to be installed. Please see the eventlog for details.'), 'SL_E_EUL_NOT_AVAILABLE' : (0xC004F034, 'The Software Licensing Service reported that the license could not be found or was invalid.'), 'SL_E_VL_NOT_WINDOWS_SLP' : (0xC004F035, 'The Software Licensing Service reported that the computer could not be activated with a Volume license product key. Volume-licensed systems require upgrading from a qualifying operating system. Please contact your system administrator or use a different type of key.'), 'SL_E_VL_NOT_ENOUGH_COUNT' : (0xC004F038, 'The Software Licensing Service reported that the product could not be activated. The count reported by your Key Management Service (KMS) is insufficient. Please contact your system administrator.'), 'SL_E_VL_BINDING_SERVICE_NOT_ENABLED' : (0xC004F039, 'The Software Licensing Service reported that the product could not be activated. The Key Management Service (KMS) is not enabled.'), 'SL_E_VL_INFO_PRODUCT_USER_RIGHT' : (0x4004F040, 'The Software Licensing Service reported that the product was activated but the owner should verify the Product Use Rights.'), 'SL_E_VL_KEY_MANAGEMENT_SERVICE_NOT_ACTIVATED' : (0xC004F041, 'The Software Licensing Service determined that the Key Management Service (KMS) is not activated. KMS needs to be activated. Please contact system administrator.'), 'SL_E_VL_KEY_MANAGEMENT_SERVICE_ID_MISMATCH' : (0xC004F042, 'The Software Licensing Service determined that the specified Key Management Service (KMS) cannot be used.'), 'SL_E_PROXY_POLICY_NOT_UPDATED' : (0xC004F047, 'The Software Licensing Service reported that the proxy policy has not been updated.'), 'SL_E_CIDIID_INVALID_CHECK_DIGITS' : (0xC004F04D, 'The Software Licensing Service determined that the Installation ID (IID) or the Confirmation ID (CID) is invalid.'), 'SL_E_LICENSE_MANAGEMENT_DATA_NOT_FOUND' : (0xC004F04F, 'The Software Licensing Service reported that license management information was not found in the licenses.'), 'SL_E_INVALID_PRODUCT_KEY' : (0xC004F050, 'The Software Licensing Service reported that the product key is invalid.'), 'SL_E_BLOCKED_PRODUCT_KEY' : (0xC004F051, 'The Software Licensing Service reported that the product key is blocked.'), 'SL_E_DUPLICATE_POLICY' : (0xC004F052, 'The Software Licensing Service reported that the licenses contain duplicated properties.'), 'SL_E_MISSING_OVERRIDE_ONLY_ATTRIBUTE' : (0xC004F053, 'The Software Licensing Service determined that the license is invalid. The license contains an override policy that is not configured properly.'), 'SL_E_LICENSE_MANAGEMENT_DATA_DUPLICATED' : (0xC004F054, 'The Software Licensing Service reported that license management information has duplicated data.'), 'SL_E_BASE_SKU_NOT_AVAILABLE' : (0xC004F055, 'The Software Licensing Service reported that the base SKU is not available.'), 'SL_E_VL_MACHINE_NOT_BOUND' : (0xC004F056, 'The Software Licensing Service reported that the product could not be activated using the Key Management Service (KMS).'), 'SL_E_SLP_MISSING_ACPI_SLIC' : (0xC004F057, 'The Software Licensing Service reported that the computer BIOS is missing a required license.'), 'SL_E_SLP_MISSING_SLP_MARKER' : (0xC004F058, 'The Software Licensing Service reported that the computer BIOS is missing a required license.'), 'SL_E_SLP_BAD_FORMAT' : (0xC004F059, 'The Software Licensing Service reported that a license in the computer BIOS is invalid.'), 'SL_E_INVALID_PACKAGE_VERSION' : (0xC004F060, 'The Software Licensing Service determined that the version of the license package is invalid.'), 'SL_E_PKEY_INVALID_UPGRADE' : (0xC004F061, 'The Software Licensing Service determined that this specified product key can only be used for upgrading, not for clean installations.'), 'SL_E_ISSUANCE_LICENSE_NOT_INSTALLED' : (0xC004F062, 'The Software Licensing Service reported that a required license could not be found.'), 'SL_E_SLP_OEM_CERT_MISSING' : (0xC004F063, 'The Software Licensing Service reported that the computer is missing a required OEM license.'), 'SL_E_NONGENUINE_GRACE_TIME_EXPIRED' : (0xC004F064, 'The Software Licensing Service reported that the non-genuine grace period expired.'), 'SL_I_NONGENUINE_GRACE_PERIOD' : (0x4004F065, 'The Software Licensing Service reported that the application is running within the valid non-genuine grace period.'), 'SL_E_DEPENDENT_PROPERTY_NOT_SET' : (0xC004F066, 'The Software Licensing Service reported that the genuine information property can not be set before dependent property been set.'), 'SL_E_NONGENUINE_GRACE_TIME_EXPIRED_2' : (0xC004F067, 'The Software Licensing Service reported that the non-genuine grace period expired (type 2).'), 'SL_I_NONGENUINE_GRACE_PERIOD_2' : (0x4004F068, 'The Software Licensing Service reported that the application is running within the valid non-genuine grace period (type 2).'), 'SL_E_MISMATCHED_PRODUCT_SKU' : (0xC004F069, 'The Software Licensing Service reported that the product SKU is not found.'), 'SL_E_OPERATION_NOT_ALLOWED' : (0xC004F06A, 'The Software Licensing Service reported that the requested operation is not allowed.'), 'SL_E_VL_KEY_MANAGEMENT_SERVICE_VM_NOT_SUPPORTED' : (0xC004F06B, 'The Software Licensing Service determined that it is running in a virtual machine. The Key Management Service (KMS) is not supported in this mode.'), 'SL_E_VL_INVALID_TIMESTAMP' : (0xC004F06C, 'The Software Licensing Service reported that the product could not be activated. The Key Management Service (KMS) determined that the request timestamp is invalid.'), 'SL_E_PLUGIN_INVALID_MANIFEST' : (0xC004F071, 'The Software Licensing Service reported that the plug-in manifest file is incorrect.'), 'SL_E_APPLICATION_POLICIES_MISSING' : (0xC004F072, 'The Software Licensing Service reported that the license policies for fast query could not be found.'), 'SL_E_APPLICATION_POLICIES_NOT_LOADED' : (0xC004F073, 'The Software Licensing Service reported that the license policies for fast query have not been loaded.'), 'SL_E_VL_BINDING_SERVICE_UNAVAILABLE' : (0xC004F074, 'The Software Licensing Service reported that the product could not be activated. No Key Management Service (KMS) could be contacted. Please see the Application Event Log for additional information.'), 'SL_E_SERVICE_STOPPING' : (0xC004F075, 'The Software Licensing Service reported that the operation cannot be completed because the service is stopping.'), 'SL_E_PLUGIN_NOT_REGISTERED' : (0xC004F076, 'The Software Licensing Service reported that the requested plug-in cannot be found.'), 'SL_E_AUTHN_WRONG_VERSION' : (0xC004F077, 'The Software Licensing Service determined incompatible version of authentication data.'), 'SL_E_AUTHN_MISMATCHED_KEY' : (0xC004F078, 'The Software Licensing Service reported that the key is mismatched.'), 'SL_E_AUTHN_CHALLENGE_NOT_SET' : (0xC004F079, 'The Software Licensing Service reported that the authentication data is not set.'), 'SL_E_AUTHN_CANT_VERIFY' : (0xC004F07A, 'The Software Licensing Service reported that the verification could not be done.'), 'SL_E_SERVICE_RUNNING' : (0xC004F07B, 'The requested operation is unavailable while the Software Licensing Service is running.'), 'SL_E_SLP_INVALID_MARKER_VERSION' : (0xC004F07C, 'The Software Licensing Service determined that the version of the computer BIOS is invalid.'), 'SL_E_INVALID_PRODUCT_KEY_TYPE' : (0xC004F07D, 'The Software Licensing Service reported that the product key cannot be used for this type of activation.'), 'SL_E_CIDIID_MISMATCHED_PKEY' : (0xC004F07E, 'The Installation ID (IID) and the Confirmation ID (CID) do not match the product key.'), 'SL_E_CIDIID_NOT_BOUND' : (0xC004F07F, 'The Installation ID (IID) and the Confirmation ID (CID) are not bound to the current environment.'), 'SL_E_LICENSE_NOT_BOUND' : (0xC004F080, 'The Software Licensing Service reported that the license is not bound to the current environment.'), 'SL_E_VL_AD_AO_NOT_FOUND' : (0xC004F081, 'The Software Licensing Service reported that the Active Directory Activation Object could not be found or was invalid.'), 'SL_E_VL_AD_AO_NAME_TOO_LONG' : (0xC004F082, 'The Software Licensing Service reported that the name specified for the Active Directory Activation Object is too long.'), 'SL_E_VL_AD_SCHEMA_VERSION_NOT_SUPPORTED' : (0xC004F083, 'The Software Licensing Service reported that Active Directory-Based Activation is not supported in the current Active Directory schema.'), 'SL_E_NOT_GENUINE' : (0xC004F200, 'The Software Licensing Service reported that current state is not genuine.'), 'SL_E_EDITION_MISMATCHED' : (0xC004F210, 'The Software Licensing Service reported that the license edition does match the computer edition.'), 'SL_E_TKA_CHALLENGE_EXPIRED' : (0xC004F301, 'The Software Licensing Service reported that the product could not be activated. The token-based activation challenge has expired.'), 'SL_E_TKA_SILENT_ACTIVATION_FAILURE' : (0xC004F302, 'The Software Licensing Service reported that Silent Activation failed. The Software Licensing Service reported that there are no certificates found in the system that could activate the product without user interaction.'), 'SL_E_TKA_INVALID_CERT_CHAIN' : (0xC004F303, 'The Software Licensing Service reported that the certificate chain could not be built or failed validation.'), 'SL_E_TKA_GRANT_NOT_FOUND' : (0xC004F304, 'The Software Licensing Service reported that required license could not be found.'), 'SL_E_TKA_CERT_NOT_FOUND' : (0xC004F305, 'The Software Licensing Service reported that there are no certificates found in the system that could activate the product.'), 'SL_E_TKA_INVALID_SKU_ID' : (0xC004F306, 'The Software Licensing Service reported that this software edition does not support token-based activation.'), 'SL_E_TKA_INVALID_BLOB' : (0xC004F307, 'The Software Licensing Service reported that the product could not be activated. Activation data is invalid.'), 'SL_E_TKA_TAMPERED_CERT_CHAIN' : (0xC004F308, 'The Software Licensing Service reported that the product could not be activated. Activation data is tampered.'), 'SL_E_TKA_CHALLENGE_MISMATCH' : (0xC004F309, 'The Software Licensing Service reported that the product could not be activated. Activation challenge and response do not match.'), 'SL_E_TKA_INVALID_CERTIFICATE' : (0xC004F30A, 'The Software Licensing Service reported that the product could not be activated. The certificate does not match the conditions in the license.'), 'SL_E_TKA_INVALID_SMARTCARD' : (0xC004F30B, 'The Software Licensing Service reported that the inserted smartcard could not be used to activate the product.'), 'SL_E_TKA_FAILED_GRANT_PARSING' : (0xC004F30C, 'The Software Licensing Service reported that the token-based activation license content is invalid.'), 'SL_E_TKA_INVALID_THUMBPRINT' : (0xC004F30D, 'The Software Licensing Service reported that the product could not be activated. The thumbprint is invalid.'), 'SL_E_TKA_THUMBPRINT_CERT_NOT_FOUND' : (0xC004F30E, 'The Software Licensing Service reported that the product could not be activated. The thumbprint does not match any certificate.'), 'SL_E_TKA_CRITERIA_MISMATCH' : (0xC004F30F, 'The Software Licensing Service reported that the product could not be activated. The certificate does not match the criteria specified in the issuance license.'), 'SL_E_TKA_TPID_MISMATCH' : (0xC004F310, 'The Software Licensing Service reported that the product could not be activated. The certificate does not match the trust point identifier (TPID) specified in the issuance license.'), 'SL_E_TKA_SOFT_CERT_DISALLOWED' : (0xC004F311, 'The Software Licensing Service reported that the product could not be activated. A soft token cannot be used for activation.'), 'SL_E_TKA_SOFT_CERT_INVALID' : (0xC004F312, 'The Software Licensing Service reported that the product could not be activated. The certificate cannot be used because its private key is exportable.'), 'SL_E_TKA_CERT_CNG_NOT_AVAILABLE' : (0xC004F313, 'The Software Licensing Service reported that the CNG encryption library could not be loaded. The current certificate may not be available on this version of Windows.'), 'E_RM_UNKNOWN_ERROR' : (0xC004FC03, 'A networking problem has occurred while activating your copy of Windows.'), 'SL_I_TIMEBASED_VALIDITY_PERIOD' : (0x4004FC04, 'The Software Licensing Service reported that the application is running within the timebased validity period.'), 'SL_I_PERPETUAL_OOB_GRACE_PERIOD' : (0x4004FC05, 'The Software Licensing Service reported that the application has a perpetual grace period.'), 'SL_I_TIMEBASED_EXTENDED_GRACE_PERIOD' : (0x4004FC06, 'The Software Licensing Service reported that the application is running within the valid extended grace period.'), 'SL_E_VALIDITY_PERIOD_EXPIRED' : (0xC004FC07, 'The Software Licensing Service reported that the validity period expired.'), 'SL_E_IA_THROTTLE_LIMIT_EXCEEDED' : (0xC004FD00, "You've reached the request limit for automatic virtual machine activation. Try again later."), 'SL_E_IA_INVALID_VIRTUALIZATION_PLATFORM' : (0xC004FD01, "Windows isn't running on a supported Microsoft Hyper-V virtualization platform."), 'SL_E_IA_PARENT_PARTITION_NOT_ACTIVATED' : (0xC004FD02, "Windows isn't activated on the host machine. Please contact your system administrator."), 'SL_E_IA_ID_MISMATCH' : (0xC004FD03, "The host machine can't activate the edition of Windows on the virtual machine."), 'SL_E_IA_MACHINE_NOT_BOUND' : (0xC004FD04, "Windows isn't activated."), 'SL_E_TAMPER_RECOVERY_REQUIRES_ACTIVATION' : (0xC004FE00, 'The Software Licensing Service reported that activation is required to recover from tampering of SL Service trusted store.'), '@ $slErrors = @{} foreach ($line in $slErrorBLock -split "`n") { if ($line -match "'(.+?)'\s*:\s*\(\s*0x([0-9A-Fa-f]+),\s*'(.+?)'\s*\)") { $name = $matches[1] $code = [int]"0x$($matches[2])" $desc = $matches[3] $slErrors[$code] = "$($name): $($desc)" } } And this.---> Code: function Init-XMLInfo { $paths = @( "C:\Windows\System32\spp\tokens\pkeyconfig\pkeyconfig.xrm-ms", "C:\Windows\System32\spp\tokens\pkeyconfig\pkeyconfig-csvlk.xrm-ms", "C:\Windows\System32\spp\tokens\pkeyconfig\pkeyconfig-downlevel.xrm-ms", "C:\Program Files\Microsoft Office\root\Licenses16\pkeyconfig-office.xrm-ms" ) $entries = @() foreach ($path in $paths) { if (Test-Path -Path $path) { $extracted = Extract-Base64Xml -FilePath $path if ($extracted) { $entries += $extracted } } } return $entries } function Extract-Base64Xml { param ( [string]$FilePath ) # Check if the file exists if (-Not (Test-Path $FilePath)) { Write-Warning "File not found: $FilePath" return $null } # Read the content of the file $content = Get-Content -Path $FilePath -Raw # Use regex to find all Base64 encoded strings between <tm:infoBin> tags $matches = [regex]::Matches($content, '<tm:infoBin name="pkeyConfigData">(.*?)<\/tm:infoBin>', [RegexOptions]::Singleline) $configurationsList = @() foreach ($match in $matches) { # Extract the Base64 encoded string $base64String = $match.Groups[1].Value.Trim() # Decode the Base64 string try { $decodedBytes = [Convert]::FromBase64String($base64String) $decodedString = [Encoding]::UTF8.GetString($decodedBytes) [xml]$xmlData = $decodedString # Process ProductKeyConfiguration #$xmlData.OuterXml | Out-File 'C:\Users\Administrator\Desktop\License.txt' if ($xmlData.ProductKeyConfiguration.Configurations) { foreach ($config in $xmlData.ProductKeyConfiguration.Configurations.ChildNodes) { # Create a PSCustomObject for each configuration $configObj = [PSCustomObject]@{ ActConfigId = $config.ActConfigId RefGroupId = $config.RefGroupId EditionId = $config.EditionId ProductDescription = $config.ProductDescription ProductKeyType = $config.ProductKeyType IsRandomized = $config.IsRandomized } $configurationsList += $configObj } } } catch { Write-Error "Failed to decode Base64 string: $_" } } # Return the list of configurations return $configurationsList } $Global:PKeyDatabase = Init-XMLInfo
Main SL Function -- Function [1/2] Update at 21-06-2025 Code: - Update Get-LicenseInfo, Add more information to extract. Code: <# .SYNOPSIS Just an public helper to read SL Activation Error's it also use $slErrors as Alternative, if error not found #> function Get-WindowsErrorMessage { [CmdletBinding()] Param( [Parameter(Mandatory=$true, ValueFromPipeline=$true, HelpMessage="Enter a decimal or hexadecimal error code (e.g., 0, 2147942405, 0x80070005)")] [string]$ErrorCode ) Process { # Convert the input to a hexadecimal string for consistent lookup try { if ($ErrorCode.StartsWith("0x", [System.StringComparison]::OrdinalIgnoreCase)) { $hrHex = $ErrorCode $uint32Value = $ErrorCode -band 0xFFFFFFFF } else { $uint32Value = $ErrorCode -band 0xFFFFFFFF $hrHex = "0x{0:X8}" -f $uint32Value } } catch { Write-Warning "Invalid input format. Please provide a valid decimal or hexadecimal string." return "Invalid input format: $ErrorCode" } $errorMessage = "Unknown error code: $hrHex" # Default message switch ($hrHex) { "0x00000000" { $errorMessage = "Valid key for product's licensing channel was used for activation." } "0x4004F040" { $errorMessage = "OS is licensed, verify the products use rights, cosmetic error as no SLIC/MSDM is present." } "0x4004F065" { $errorMessage = "Application is running within the valid non-genuine grace allowance." } "0x4004F068" { $errorMessage = "This computer is running within the valid non-genuine grace allowance {type 2}." } "0x4004F401" { $errorMessage = "This computer has a valid Digital/Store License." } "0x4004FC04" { $errorMessage = "This computer is running within the time-based validity allowance." } "0x4004FC05" { $errorMessage = "This computer has a perpetual grace allowance." } "0x4004FC06" { $errorMessage = "This computer is running within the valid extended grace allowance." } "0x4004F00C" { $errorMessage = "Running within the valid grace allowance." } "0x4004F00D" { $errorMessage = "Running within the valid out of tolerance grace allowance." } "0x80004001" { $errorMessage = "The operation is not supported." } "0x80004002" { $errorMessage = "No such interface supported." } "0x80004003" { $errorMessage = "Invalid pointer." } "0x80004004" { $errorMessage = "Operation aborted." } "0x80004005" { $errorMessage = "Activation {SLUI.exe} failed. Try activating manually via 'Activate Windows' screen." } "0x80004006" { $errorMessage = "Thread local storage failure." } "0x80004007" { $errorMessage = "Shared memory allocator failure." } "0x80004008" { $errorMessage = "Memory allocator failure." } "0x80004009" { $errorMessage = "Unable to initialize class cache." } "0x8000400A" { $errorMessage = "Unable to initialize RPC services" } "0x8000400B" { $errorMessage = "Cannot set thread local storage channel control." } "0x8000400C" { $errorMessage = "Could not allocate thread local storage channel control." } "0x8000400D" { $errorMessage = "The user supplied memory allocator is unacceptable." } "0x8000400E" { $errorMessage = "The OLE service mutex already exists." } "0x8000400F" { $errorMessage = "The OLE service file mapping already exists." } "0x80004010" { $errorMessage = "Unable to map view of file for OLE service" } "0x80040150" { $errorMessage = "Could not read information from registry." } "0x80040151" { $errorMessage = "Could not write information to registry." } "0x80040152" { $errorMessage = "Possible problems with Windows Update services." } "0x80040153" { $errorMessage = "Invalid value for registry. RegisterDCOM. System configuration error." } "0x80040154" { $errorMessage = "Detected either unregistered files or possible registry corruption." } "0x80040155" { $errorMessage = "Class interface not registered. DCOM. C++ runtime etc." } "0x80040156" { $errorMessage = "Class interface not registered. COM. Threading model entry error." } "0x80040157" { $errorMessage = "Registration within a package violates package-specific policies." } "0x80041002" { $errorMessage = "The WMI repository may be corrupt. {WBEM_E_NOT_FOUND}" } "0x8004D102" { $errorMessage = "Machine time is inconsistent with the trusted time. Check time/date." } "0x8004D10B" { $errorMessage = "The security processor cannot operate while a debugger is attached." } "0x8004E026" { $errorMessage = "Valid product key for an add-on sku was entered when a Windows product key was expected." } "0x8004E101" { $errorMessage = "Token Store file version is invalid." } "0x8004E102" { $errorMessage = "Token Store contains an invalid descriptor table." } "0x8004E103" { $errorMessage = "Token Store contains a token with an invalid header/footer." } "0x8004E104" { $errorMessage = "Token Store token has an invalid name." } "0x8004E105" { $errorMessage = "Token Store token has an invalid extension." } "0x8004E106" { $errorMessage = "Token Store contains a duplicate token." } "0x8004E107" { $errorMessage = "Token Store has a size mismatch." } "0x8004E108" { $errorMessage = "Token Store contains an invalid hash." } "0x8004E109" { $errorMessage = "Token Store was unable to read a token." } "0x8004E10A" { $errorMessage = "Token Store was unable to write a token." } "0x8004E10B" { $errorMessage = "Token Store attempted an invalid file operation." } "0x8004E10C" { $errorMessage = "Token Store has no active transaction." } "0x8004E10D" { $errorMessage = "Token Store file header is invalid." } "0x8004E10E" { $errorMessage = "Token Store token descriptor is invalid." } "0x8004FE21" { $errorMessage = "This computer is not running genuine Windows." } "0x80070001" { $errorMessage = "Incorrect function." } "0x80070002" { $errorMessage = "Windows Datastore folder content mismatch, or network connectivity issue." } "0x80070003" { $errorMessage = "The system cannot find the path specified." } "0x80070004" { $errorMessage = "The system cannot open the file. Too many open files." } "0x80070005" { $errorMessage = "Access denied. The requested action requires elevated privileges." } "0x80070006" { $errorMessage = "The handle is invalid." } "0x80070007" { $errorMessage = "The storage control blocks were destroyed." } "0x80070008" { $errorMessage = "Not enough storage is available to process this command." } "0x80070009" { $errorMessage = "The storage control block address is invalid." } "0x8007000A" { $errorMessage = "The environment is incorrect." } "0x8007000B" { $errorMessage = "An attempt was made to load a program with an incorrect format." } "0x8007000C" { $errorMessage = "The access code is invalid." } "0x8007000D" { $errorMessage = "The data is invalid. Maybe multiple TAP adaptors." } "0x8007000E" { $errorMessage = "Not enough storage is available to complete this operation." } "0x8007000F" { $errorMessage = "The system cannot find the drive specified." } "0x8007007B" { $errorMessage = "This issue may occur if the KMS client cannot find the KMS SRV resource records in DNS." } "0x80070300" { $errorMessage = "Exception occurred in a user mode callback and the kernel callback frame should be removed." } "0x80070302" { $errorMessage = "The data provider cannot fetch backwards through a result set." } "0x80070306" { $errorMessage = "One or more errors occurred while processing the request." } "0x80070307" { $errorMessage = "The implementation is not capable of performing the request." } "0x80070309" { $errorMessage = "Version number could not be parsed." } "0x8007030B" { $errorMessage = "The hardware has reported an uncorrectable memory error." } "0x8007030D" { $errorMessage = "The Desktop heap encountered an error while allocating session memory." } "0x80070312" { $errorMessage = "Access has been restricted by your Administrator by policy rule." } "0x80070326" { $errorMessage = "Access to the specified file handle has been revoked." } "0x80070422" { $errorMessage = "Service cannot be started, because it is disabled or no enabled devices associated with it." } "0x80070426" { $errorMessage = "Call to GetEndpointToken failed. Check if Remote Procedure Call {RPC} services are started." } "0x8007047F" { $errorMessage = "The specified program is not a Windows program." } "0x80070480" { $errorMessage = "Cannot start more than one instance of the specified program." } "0x80070481" { $errorMessage = "The specified program was written for an earlier version of Windows." } "0x80070482" { $errorMessage = "One of the library files needed to run this application is damaged." } "0x80070484" { $errorMessage = "An error occurred in sending the command to the application." } "0x80070485" { $errorMessage = "One of the library files needed to run this application cannot be found." } "0x80070490" { $errorMessage = "Corrupted file or process in the System Component Store or in Component-Based Servicing." } "0x80070491" { $errorMessage = "There was no match for the specified key in the index." } "0x80070492" { $errorMessage = "The Specified property set is not supported." } "0x80070493" { $errorMessage = "The point passed to GetMouseMovePoints is not in the buffer." } "0x80070494" { $errorMessage = "The tracking {Workstation} service is not running." } "0x80070495" { $errorMessage = "The Volume ID could not be found." } "0x80070497" { $errorMessage = "Unable to remove the file to be replaced." } "0x800704CF" { $errorMessage = "The network location can't be reached or activation server busy, try later." } "0x800706BA" { $errorMessage = "RPC server is unavailable. Firewall settings are not configured on the KMS host, or DNS." } "0x8007139A" { $errorMessage = "The cluster resource could not be brought online by the resource monitor." } "0x8007139B" { $errorMessage = "The operation could not be completed because the cluster resource is online." } "0x8007139C" { $errorMessage = "The cluster resource could not be deleted/brought offline because it is the quorum resource." } "0x8007139D" { $errorMessage = "The cluster could not be capable of being a quorum resource." } "0x8007139E" { $errorMessage = "The cluster software is shutting down." } "0x8007139F" { $errorMessage = "The group or resource is not in the correct state to perform the requested operation." } "0x8007232A" { $errorMessage = "DNS server failure. The system has network or DNS issues." } "0x8007232B" { $errorMessage = "Windows could not be activated. KMS or DNS host could not be located in domain name system." } "0x8007251D" { $errorMessage = "No records found for DNS query. Troubleshoot network connections and DNS." } "0x8007267C" { $errorMessage = "No DNS servers configured for local system, no internet connection." } "0x80072EE7" { $errorMessage = "Cannot connect to internet on your device to activate or install any updates." } "0x80072EFE" { $errorMessage = "Date/Time out of sync, check date/time is correct. Root Certificate authentication error." } "0x80072F8F" { $errorMessage = "The computer's system time does not match the system time of the Activation Server." } "0x800736B3" { $errorMessage = "Missing or corrupted .Net Framework." } "0x80080005" { $errorMessage = "Windows has detected a problem with the update service. Run Windows Update Troubleshooter." } "0x80092328" { $errorMessage = "This issue may occur if the KMS client cannot find the KMS SRV resource records in DNS." } "0x800B0001" { $errorMessage = "Unknown trust provider." } "0x800B0005" { $errorMessage = "Error due to problem in ASN.1 encoding process." } "0x800B0009" { $errorMessage = "The size of the data could not be determined." } "0x800B000B" { $errorMessage = "This object does not read and write self-sizing data." } "0x800B0100" { $errorMessage = "No signature was present in the subject." } "0x800B0105" { $errorMessage = "Certificate contains an unknown extension that is marked 'critical'." } "0x800B0109" { $errorMessage = "Root certificate is not trusted by the trust provider." } "0x800B010C" { $errorMessage = "Certificate was explicitly revoked by its issuer." } "0x800B010E" { $errorMessage = "The revocation process could not continue - the certificate{s} could not be checked." } "0x800B010F" { $errorMessage = "The certificate's CN name does not match the passed value." } "0x800B0112" { $errorMessage = "One of the CA certificates is not trusted by the policy provider." } "0x800B0114" { $errorMessage = "The certificate has an invalid name." } "0x800F080C" { $errorMessage = "A Windows feature name was not recognized. Possible Net Framework error." } "0x800F0950" { $errorMessage = "There may be a problem with v3.5 .Net installation." } "0x8024402F" { $errorMessage = "Possible corrupted Windows Update file, try running Windows Update Troubleshooter." } "0x8024A223" { $errorMessage = "There may be a problem with a .Net installation." } "0x8033803F" { $errorMessage = "The Windows Store Management service is busy servicing other requests." } "0x800F0922" { $errorMessage = "Windows Update or .NET Framework component failure." } "0x803F7001" { $errorMessage = "Activation failed because this device doesn't have a valid digital license or product key." } "0x803F7003" { $errorMessage = "Device Limit Reached - Store Error." } "0x803F7004" { $errorMessage = "Windows Store Error - Undocumented." } "0x803F8001" { $errorMessage = "The Store Agent can't acquire license for this app." } "0x803FA065" { $errorMessage = "The specified product key is invalid." } "0x803FA066" { $errorMessage = "There is a problem with the specified product key." } "0x803FA067" { $errorMessage = "The specified product key has been blocked." } "0x803FA068" { $errorMessage = "The specified product key has been blocked." } "0x803FA06C" { $errorMessage = "The specified product key is invalid." } "0x803FA071" { $errorMessage = "The activation server reported that the product key has exceeded its unlock limit." } "0x803FA073" { $errorMessage = "The licence is invalid." } "0x803FA074" { $errorMessage = "The licence is invalid." } "0x803FA076" { $errorMessage = "The activation server determined the product key is not valid." } "0x803FA077" { $errorMessage = "The specified product key is invalid." } "0x803FA078" { $errorMessage = "The specified product key is invalid." } "0x803FA07A" { $errorMessage = "The licence is invalid." } "0x803FA07D" { $errorMessage = "The activation server experienced an error. Try again later." } "0x803FA07F" { $errorMessage = "The Multiple Activation Key has exceeded its limit." } "0x803FA080" { $errorMessage = "The Multiple Activation Key extension limit has been exceeded." } "0x803FA083" { $errorMessage = "The specified product key cannot be used for online activation." } "0x803FA08D" { $errorMessage = "The version of the offline Confirmation ID {CID} is incorrect." } "0x803FA08E" { $errorMessage = "The format for the offline activation data is incorrect." } "0x803FA08F" { $errorMessage = "The length of the offline Confirmation ID {CID} is incorrect." } "0x803FA090" { $errorMessage = "The Installation ID {IID} or the Confirmation ID {CID} is invalid." } "0x803FA097" { $errorMessage = "Time-based activation attempted before start date." } "0x803FA098" { $errorMessage = "Time-based activation attempted after end date." } "0x803FA099" { $errorMessage = "The new time-based activation is not available." } "0x803FA09A" { $errorMessage = "The time-based product key is not configured for activation." } "0x803FA0C8" { $errorMessage = "No business rules are available to activate the specified product key." } "0x803FA0CB" { $errorMessage = "The specified product key has been blocked for this geographic location." } "0x803FA0D3" { $errorMessage = "The licence is invalid." } "0x803FA0D4" { $errorMessage = "There is a problem with the specified product key." } "0x803FA0D5" { $errorMessage = "The override limit has been reached." } "0x803FA0D6" { $errorMessage = "The override limit has been reached." } "0x803FA400" { $errorMessage = "The offer no longer exists." } "0x803FABB8" { $errorMessage = "The donor hardware ID does not own operating system entitlement." } "0x803FABB9" { $errorMessage = "The user is not eligible for reactivation {Generic error code}." } "0x803FABBA" { $errorMessage = "The user is not eligible for reactivation due to no association." } "0x803FABBB" { $errorMessage = "The user is not eligible for reactivation because the user is not an admin on the device." } "0x803FABBC" { $errorMessage = "The user is not eligible for reactivation because the user is throttled." } "0x803FABBD" { $errorMessage = "The user is not eligible for reactivation because the licence is throttled." } "0x803FABBE" { $errorMessage = "The device is not eligible for reactivation because it is throttled." } "0x803FABBF" { $errorMessage = "The user is not eligible for reactivation because policy does not allow it." } "0x803FABC0" { $errorMessage = "The device is not eligible for reactivation because it is blocked." } "0x803FABC1" { $errorMessage = "The user is not eligible for reactivation because the user is blocked." } "0x803FABC2" { $errorMessage = "The license is not eligible for transfer because the licence is blocked." } "0x803FABC3" { $errorMessage = "The device is not eligible for transfer because the device is blocked." } "0x87E10BC6" { $errorMessage = "The requested content ID could not be found in the catalog." } "0xC0000022" { $errorMessage = "Files maybe corrupted, have access issues or security software interference." } "0xC0020036" { $errorMessage = "There are no more endpoints available from the endpoint mapper." } "0xC004B001" { $errorMessage = "Invalid Publish License. Computer could not be activated." } "0xC004B002" { $errorMessage = "Invalid Product Key License. Computer could not be activated." } "0xC004B003" { $errorMessage = "Invalid Rights Account License. Could not be activated." } "0xC004B004" { $errorMessage = "Invalid License Structure. Computer could not be activated." } "0xC004B005" { $errorMessage = "Authorization Failed. Computer could not be activated." } "0xC004B006" { $errorMessage = "Invalid Binding. Computer could not be activated." } "0xC004B007" { $errorMessage = "The computer could not connect to the activation server." } "0xC004B008" { $errorMessage = "Invalid Payload. Computer could not be activated." } "0xC004B009" { $errorMessage = "Invalid Security Processor License." } "0xC004B010" { $errorMessage = "The required business token entry cannot be found." } "0xC004B011" { $errorMessage = "The computer clock time is not correct. You must correct the clock before you can activate." } "0xC004B100" { $errorMessage = "The product could not be activated. This issue may occur if gVLK/MAK is unsupported." } "0xC004C001" { $errorMessage = "The specified product key is invalid." } "0xC004C002" { $errorMessage = "Activation server determined there is a problem with the specified product key." } "0xC004C003" { $errorMessage = "The specified product key has been blocked or invalid." } "0xC004C004" { $errorMessage = "Product key can't be used to activate Windows. Enter a different product key." } "0xC004C005" { $errorMessage = "Binding Not Found, licence is invalid." } "0xC004C006" { $errorMessage = "Binding Mapping Not Found, licence is invalid." } "0xC004C007" { $errorMessage = "The specified product key is invalid." } "0xC004C008" { $errorMessage = "Product key has exceeded its unlock limit." } "0xC004C009" { $errorMessage = "Activation Configuration ID not found." } "0xC004C00A" { $errorMessage = "Invalid Product Data ID, the license is invalid." } "0xC004C00B" { $errorMessage = "Invalid Product Data, the licence is invalid." } "0xC004C00C" { $errorMessage = "Activation Server has experienced an error, try again later." } "0xC004C00D" { $errorMessage = "Invalid Activation Configuration ID." } "0xC004C00E" { $errorMessage = "Invalid Product Key Length." } "0xC004C00F" { $errorMessage = "Invalid Product Key Format." } "0xC004C010" { $errorMessage = "Invalid Product Key Character." } "0xC004C011" { $errorMessage = "Invalid Product Key Binding." } "0xC004C012" { $errorMessage = "Activation Server has experienced a network error, try again later." } "0xC004C013" { $errorMessage = "Activation Server is temporarily unavailable, try again later." } "0xC004C014" { $errorMessage = "Activation Server is temporarily unavailable, try again later." } "0xC004C015" { $errorMessage = "Activation Server response not available at this time, try again later." } "0xC004C016" { $errorMessage = "The OEM SLP COA Key cannot be used for online activation." } "0xC004C017" { $errorMessage = "Specified product key has been blocked for this geographic location." } "0xC004C020" { $errorMessage = "The Multiple Activation Key has exceeded its limit." } "0xC004C021" { $errorMessage = "The Multiple Activation Key extension limit has been exceeded." } "0xC004C022" { $errorMessage = "The re-issuance limit was not found." } "0xC004C023" { $errorMessage = "The override request was not found." } "0xC004C030" { $errorMessage = "Time-based activation attempted before start date." } "0xC004C031" { $errorMessage = "Time-based activation attempted after end date." } "0xC004C032" { $errorMessage = "New time-based activation is not available." } "0xC004C033" { $errorMessage = "The time-based product key is not configured for activation." } "0xC004C04F" { $errorMessage = "No business rules are available to activate the specified product key." } "0xC004C050" { $errorMessage = "The activation server experienced a general error." } "0xC004C051" { $errorMessage = "The licence is invalid." } "0xC004C052" { $errorMessage = "There is a problem with the specified product key." } "0xC004C060" { $errorMessage = "The specified product key has been blocked." } "0xC004C291" { $errorMessage = "The licence state is invalid." } "0xC004C292" { $errorMessage = "The licence state is invalid." } "0xC004C2F6" { $errorMessage = "The validation input template identifier is invalid." } "0xC004C2FA" { $errorMessage = "The validation input data is invalid." } "0xC004C327" { $errorMessage = "The validation input data parameter is invalid." } "0xC004C328" { $errorMessage = "The client token data is invalid." } "0xC004C329" { $errorMessage = "The offline data is invalid." } "0xC004C32A" { $errorMessage = "The offline data parameter is invalid." } "0xC004C32B" { $errorMessage = "The validation template identifier is invalid for this version of the Operating System." } "0xC004C32C" { $errorMessage = "The offline genuine data is revoked." } "0xC004C32D" { $errorMessage = "The offline genuine data is not found." } "0xC004C3FF" { $errorMessage = "The VGA service response is not available in the expected format." } "0xC004C401" { $errorMessage = "The product key is invalid for this version of the Operating System." } "0xC004C4A1" { $errorMessage = "The file hash is invalid." } "0xC004C4A2" { $errorMessage = "The product key has been blocked." } "0xC004C4A4" { $errorMessage = "The product key type is invalid." } "0xC004C4A5" { $errorMessage = "The product key is invalid." } "0xC004C4A7" { $errorMessage = "The OEM or Volume binding data is invalid." } "0xC004C4A8" { $errorMessage = "The licence state is invalid." } "0xC004C4A9" { $errorMessage = "The specified product key has been blocked for this geographic location." } "0xC004C4AB" { $errorMessage = "Genuine Validation detected Windows licensing exploits." } "0xC004C4AC" { $errorMessage = "The token activation data is invalid." } "0xC004C4AD" { $errorMessage = "Genuine Validation detected tampered Windows binaries." } "0xC004C4AE" { $errorMessage = "Genuine Validation detected tampered Windows binaries." } "0xC004C4AF" { $errorMessage = "The active directory activation data is invalid." } "0xC004C4B0" { $errorMessage = "Genuine Validation detected Windows licensing exploits." } "0xC004C4B1" { $errorMessage = "Genuine Validation detected Windows licensing exploits." } "0xC004C531" { $errorMessage = "Genuine Validation detected Windows licensing exploits." } "0xC004C532" { $errorMessage = "The licence state is in notification due to expired grace." } "0xC004C533" { $errorMessage = "The licence state is in notification." } "0xC004C600" { $errorMessage = "Your copy of Windows is not genuine." } "0xC004C700" { $errorMessage = "Business rule could not find required input." } "0xC004C750" { $errorMessage = "NULL value specified for business property name and ID." } "0xC004C751" { $errorMessage = "Property name specifies unknown property." } "0xC004C752" { $errorMessage = "Property ID specifies unknown property." } "0xC004C755" { $errorMessage = "Failed to update product key binding." } "0xC004C756" { $errorMessage = "Failed to insert product key binding." } "0xC004C757" { $errorMessage = "Failed to delete product key binding." } "0xC004C758" { $errorMessage = "Failed to process input XML for product key bindings." } "0xC004C75A" { $errorMessage = "Failed to insert product key property." } "0xC004C75B" { $errorMessage = "Failed to update product key property." } "0xC004C75C" { $errorMessage = "Failed to delete product key property." } "0xC004C764" { $errorMessage = "The product key type is unknown." } "0xC004C770" { $errorMessage = "The product key type is being used by another user." } "0xC004C780" { $errorMessage = "Failed to insert product key record." } "0xC004C781" { $errorMessage = "Failed to update product key record." } "0xC004C801" { $errorMessage = "Specified product key is invalid." } "0xC004C802" { $errorMessage = "Specified product key is invalid." } "0xC004C803" { $errorMessage = "Specified product key has been revoked." } "0xC004C804" { $errorMessage = "Specified product key is invalid." } "0xC004C805" { $errorMessage = "Specified product key is invalid." } "0xC004C810" { $errorMessage = "Specified product key is invalid." } "0xC004C811" { $errorMessage = "License is invalid." } "0xC004C812" { $errorMessage = "Product key has exceeded its activation count." } "0xC004C813" { $errorMessage = "License is invalid." } "0xC004C814" { $errorMessage = "Specified product key is invalid." } "0xC004C815" { $errorMessage = "License is invalid." } "0xC004C816" { $errorMessage = "Product key cannot be used for online activation." } "0xC004D301" { $errorMessage = "The trusted data store was tampered." } "0xC004D302" { $errorMessage = "The trusted data store was rearmed." } "0xC004D303" { $errorMessage = "The trusted store has been recreated." } "0xC004D304" { $errorMessage = "The entry key was not found in the trusted data store." } "0xC004D305" { $errorMessage = "The entry key already exists in the trusted data store." } "0xC004D306" { $errorMessage = "The entry key is too big to fit in the trusted data store." } "0xC004D307" { $errorMessage = "The maximum allowed number of re-arms has been exceeded." } "0xC004D308" { $errorMessage = "The entry data size is too big to fit in the trusted data store." } "0xC004D309" { $errorMessage = "The machine has gone out of hardware tolerance. Too many activations." } "0xC004D30A" { $errorMessage = "The secure timer already exists." } "0xC004D30B" { $errorMessage = "The secure timer was not found." } "0xC004D30C" { $errorMessage = "The secure timer has expired." } "0xC004D30D" { $errorMessage = "The secure timer name is too long." } "0xC004D30E" { $errorMessage = "The trusted data store is full." } "0xC004D310" { $errorMessage = "COM/OLE Interface management - Read-only entry cannot be modified." } "0xC004D311" { $errorMessage = "COM/OLE Interface management - Read-only entry cannot be modified." } "0xC004E001" { $errorMessage = "Specified context is invalid." } "0xC004E002" { $errorMessage = "License store contains inconsistent data." } "0xC004E003" { $errorMessage = "License evaluation failed." } "0xC004E004" { $errorMessage = "License has not been evaluated." } "0xC004E005" { $errorMessage = "License is not activated." } "0xC004E006" { $errorMessage = "License contains invalid data." } "0xC004E007" { $errorMessage = "License store does not contain the requested license." } "0xC004E008" { $errorMessage = "License property is invalid." } "0xC004E009" { $errorMessage = "License store is not initialized." } "0xC004E00A" { $errorMessage = "License store is already initialized." } "0xC004E00B" { $errorMessage = "License property is invalid." } "0xC004E00C" { $errorMessage = "License could not be opened or created." } "0xC004E00D" { $errorMessage = "License could not be written." } "0xC004E00E" { $errorMessage = "License store could not read the license file." } "0xC004E00F" { $errorMessage = "License property is corrupted." } "0xC004E010" { $errorMessage = "License property is missing." } "0xC004E011" { $errorMessage = "License store contains an invalid license file." } "0xC004E012" { $errorMessage = "License store failed to start synchronization properly." } "0xC004E013" { $errorMessage = "License store failed to synchronize properly." } "0xC004E014" { $errorMessage = "License property is invalid." } "0xC004E015" { $errorMessage = "License consumption failed." } "0xC004E016" { $errorMessage = "Product key is invalid." } "0xC004E017" { $errorMessage = "Product key is invalid." } "0xC004E018" { $errorMessage = "Product key is invalid." } "0xC004E019" { $errorMessage = "Validation of the specified product key failed." } "0xC004E01A" { $errorMessage = "Invalid add-on information was found." } "0xC004E01B" { $errorMessage = "Not all hardware information could be collected." } "0xC004E01C" { $errorMessage = "This evaluation product key is no longer valid." } "0xC004E01D" { $errorMessage = "The new product key cannot be used on this installation of Windows." } "0xC004E01E" { $errorMessage = "The new product key cannot be used on this installation of Windows. Error {AB-AB}" } "0xC004E01F" { $errorMessage = "The new product key cannot be used on this installation of Windows. Error {AB-CD}" } "0xC004E020" { $errorMessage = "There is a mismatch between a policy value and information stored in the OtherInfo section." } "0xC004E021" { $errorMessage = "Genuine information contained in the license is not consistent." } "0xC004E022" { $errorMessage = "Secure Store ID value in license does not match with the current value." } "0xC004D000" { $errorMessage = "Invalid License. {Remapping Security Processor Publish API}." } "0xC004D009" { $errorMessage = "The transaction manager doesn't support an asynchronous operation for this method." } "0xC004D00C" { $errorMessage = "Too Many Loaded Environments." } "0xC004D012" { $errorMessage = "Invalid Get-Information Query." } "0xC004D02C" { $errorMessage = "Invalid Handle." } "0xC004D055" { $errorMessage = "Invalid Key Length." } "0xC004D073" { $errorMessage = "No AES Provider." } "0xC004D081" { $errorMessage = "The handle was used before calling SPCommit with it." } "0xC004D101" { $errorMessage = "The security processor reported an initialization error." } "0xC004D103" { $errorMessage = "The security processor reported that an error has occurred." } "0xC004D104" { $errorMessage = "The security processor reported that invalid data was used." } "0xC004D105" { $errorMessage = "The security processor reported that the value already exists." } "0xC004D107" { $errorMessage = "The security processor reported that an insufficient buffer was used." } "0xC004D108" { $errorMessage = "The security processor reported that invalid data was used." } "0xC004D109" { $errorMessage = "An invalid Security Processor API call was made." } "0xC004D10A" { $errorMessage = "The security processor reported a version mismatch error." } "0xC004D10B" { $errorMessage = "The security processor cannot operate while a debugger is attached." } "0xC004D10C" { $errorMessage = "No more data is available for the security processor." } "0xC004D201" { $errorMessage = "The length of the cryptographic key material data is invalid" } "0xC004D202" { $errorMessage = "The block length is not correct for this algorithm" } "0xC004D203" { $errorMessage = "The Cryptographic cypher/algorithm type is invalid" } "0xC004D204" { $errorMessage = "The specified cypher mode is invalid." } "0xC004D205" { $errorMessage = "The SPAPIID for the specified Cryptographic Provider is unknown." } "0xC004D206" { $errorMessage = "The SPAPIID for the specified Cryptographic Key {type} is unknown." } "0xC004D207" { $errorMessage = "The SPAPIID for the specified Cryptographic Hash is unknown." } "0xC004D208" { $errorMessage = "The SPAPIID for the specified Cryptographic Attribute is unknown." } "0xC004D209" { $errorMessage = "The hash object has been finalised and can no longer be updated." } "0xC004D20A" { $errorMessage = "The key is not available within the current state." } "0xC004D20B" { $errorMessage = "The key does not exist. It may not have been created yet." } "0xC004D20C" { $errorMessage = "The data length is not a multiple of the algorithm's block length." } "0xC004D20D" { $errorMessage = "The length of the signature is not valid." } "0xC004D20E" { $errorMessage = "The signature does not correlate with the comparison hash." } "0xC004D20F" { $errorMessage = "The RSA block is not valid." } "0xC004D210" { $errorMessage = "The format of the RSA block is not valid." } "0xC004D211" { $errorMessage = "The CBC padding is not valid." } "0xC004D301" { $errorMessage = "Trusted data store was tampered." } "0xC004D302" { $errorMessage = "Trusted data store was rearmed." } "0xC004D303" { $errorMessage = "Trusted store has been recreated." } "0xC004D304" { $errorMessage = "That entry key was not found in the trusted data store." } "0xC004D305" { $errorMessage = "Key already exists in the trusted data store." } "0xC004D306" { $errorMessage = "Key is too big to fit in the trusted data store." } "0xC004D307" { $errorMessage = "Maximum allowed number of re-arms has been exceeded. You must re-install the OS." } "0xC004D308" { $errorMessage = "Data size is too big to fit in the trusted data store." } "0xC004D309" { $errorMessage = "The machine has gone out of hardware tolerance." } "0xC004D30A" { $errorMessage = "The secure timer already exists." } "0xC004D30B" { $errorMessage = "The secure timer was not found." } "0xC004D30C" { $errorMessage = "The secure timer has expired." } "0xC004D30D" { $errorMessage = "The secure timer name is too long." } "0xC004D30E" { $errorMessage = "Trusted data store is full." } "0xC004D310" { $errorMessage = "Read-only entry cannot be modified." } "0xC004D311" { $errorMessage = "Read-only timer cannot be modified." } "0xC004D312" { $errorMessage = "Read-only attribute cannot be modified." } "0xC004D313" { $errorMessage = "Attribute not found." } "0xC004D314" { $errorMessage = "Trusted Store access denied." } "0xC004D315" { $errorMessage = "Namespace not found." } "0xC004D316" { $errorMessage = "Namespace in use." } "0xC004D317" { $errorMessage = "Trusted store load tampered with." } "0xC004D318" { $errorMessage = "Trusted store generation tampered with." } "0xC004D319" { $errorMessage = "Trusted store tampered with, invalid data." } "0xC004D31A" { $errorMessage = "Trusted store tampered with, no data present." } "0xC004D31B" { $errorMessage = "Trusted store tampered with, data mismatch." } "0xC004D31C" { $errorMessage = "Trusted store tampered with, data version mismatch." } "0xC004D401" { $errorMessage = "Security processor reported a system file mismatch error. {Tampering Detected}." } "0xC004D402" { $errorMessage = "Security processor reported Security_Processor_Patched {Tampering Detected}." } "0xC004D501" { $errorMessage = "Security processor reported an error with the kernel data {Tampering Detected}." } "0xC004D502" { $errorMessage = "Kernel Mode Cache is tampered and the restore attempt failed." } "0xC004D701" { $errorMessage = "External decryption key was already set for specified feature." } "0xC004D702" { $errorMessage = "Error occurred during proxy execution." } "0xC004E001" { $errorMessage = "The specified context is invalid." } "0xC004E002" { $errorMessage = "License store contains inconsistent data." } "0xC004E003" { $errorMessage = "License evaluation failed." } "0xC004E004" { $errorMessage = "License has not been evaluated." } "0xC004E005" { $errorMessage = "License is not activated." } "0xC004E006" { $errorMessage = "License contains invalid data." } "0xC004E007" { $errorMessage = "License store does not contain the requested licence." } "0xC004E008" { $errorMessage = "License property is invalid." } "0xC004E009" { $errorMessage = "License store is not initialised." } "0xC004E00A" { $errorMessage = "License store is already initialised." } "0xC004E00B" { $errorMessage = "License property is invalid." } "0xC004E00C" { $errorMessage = "License could not be opened or created." } "0xC004E00D" { $errorMessage = "License could not be written." } "0xC004E00E" { $errorMessage = "License store could not read the licence file." } "0xC004E00F" { $errorMessage = "License property is corrupted." } "0xC004E010" { $errorMessage = "License property is missing." } "0xC004E011" { $errorMessage = "License store contains an invalid licence file." } "0xC004E012" { $errorMessage = "License store failed to start synchronisation properly." } "0xC004E013" { $errorMessage = "License store failed to synchronise properly." } "0xC004E014" { $errorMessage = "License property is invalid." } "0xC004E015" { $errorMessage = "License consumption failed." } "0xC004E016" { $errorMessage = "Error installing product key {PKey_Invalid_Config}." } "0xC004E017" { $errorMessage = "The product key is invalid {PKey_Invalid_UniqueID}." } "0xC004E018" { $errorMessage = "Product key is invalid {Pkey_Invalid_Algorithm}." } "0xC004E019" { $errorMessage = "Validation of the specified product key failed." } "0xC004E01A" { $errorMessage = "Invalid add-on information was found." } "0xC004E01B" { $errorMessage = "Not all hardware information could be collected." } "0xC004E01C" { $errorMessage = "This evaluation product key is no longer valid." } "0xC004E01D" { $errorMessage = "The new product key cannot be used on this installation of Windows." } "0xC004E01E" { $errorMessage = "The new product key cannot be used on this installation of Windows." } "0xC004E020" { $errorMessage = "There is a mismatch between a policy value and information stored in the OtherInfo section." } "0xC004E021" { $errorMessage = "Genuine information contained in the licence is not consistent." } "0xC004E022" { $errorMessage = "Secure store ID value in licence does not match with the current value." } "0xC004E023" { $errorMessage = "Notification rules appear to be invalid." } "0xC004E024" { $errorMessage = "Reported machine data appears to be invalid." } "0xC004E025" { $errorMessage = "Data hash does not correspond to the data." } "0xC004E027" { $errorMessage = "Version of SPPSvc does not match the policy." } "0xC004E028" { $errorMessage = "Another activation attempt is in progress for this sku." } "0xC004E029" { $errorMessage = "Activated licence requires a corresponding Store upgrade licence in order to work." } "0xC004E02A" { $errorMessage = "Store upgrade licence is not enabled for the current OS edition." } "0xC004E02B" { $errorMessage = "Store upgrade licence does not match the current active product key." } "0xC004E02C" { $errorMessage = "Store upgrade licence does not match the current signing level for the installed OS." } "0xC004E02D" { $errorMessage = "Store upgrade licence does not enable the current version of the installed OS." } "0xC004E02E" { $errorMessage = "Store upgrade licence could not be authorised." } "0xC004F001" { $errorMessage = "The Software Licensing Service reported an internal error." } "0xC004F002" { $errorMessage = "Rights consumption failed." } "0xC004F003" { $errorMessage = "Required licence could not be found." } "0xC004F004" { $errorMessage = "Product key does not match the range defined in the licence." } "0xC004F005" { $errorMessage = "Product key does not match the product key for the licence." } "0xC004F006" { $errorMessage = "Signature file for the licence is not available." } "0xC004F007" { $errorMessage = "License could not be found or is invalid." } "0xC004F008" { $errorMessage = "License could not be found or the specified product key could not be used." } "0xC004F009" { $errorMessage = "The grace allowance expired before the system was activated. System in notification state." } "0xC004F00A" { $errorMessage = "Application ID does not match the application ID for the licence." } "0xC004F00B" { $errorMessage = "Product identification data is not available." } "0xC004F00C" { $errorMessage = "Running within the valid grace allowance." } "0xC004F00D" { $errorMessage = "Running within the valid out of tolerance grace allowance." } "0xC004F00E" { $errorMessage = "The licence could not be used by the current version of the security processor component." } "0xC004F00F" { $errorMessage = "ID binding is beyond the level of tolerance. Too many changes, or antivirus interference." } "0xC004F010" { $errorMessage = "Product key is invalid." } "0xC004F011" { $errorMessage = "License file is not installed." } "0xC004F012" { $errorMessage = "Value for the input key was not found." } "0xC004F013" { $errorMessage = "There is no permission to run the software." } "0xC004F014" { $errorMessage = "Product key is not available. No product keys are installed on the system. {KMS}" } "0xC004F015" { $errorMessage = "License consumption failed. Key ID mismatch." } "0xC004F016" { $errorMessage = "The request is not supported." } "0xC004F017" { $errorMessage = "The license is not installed. Incorrect License may of been used for this Edition/Channel." } "0xC004F018" { $errorMessage = "License does not contain valid location data for the activation server." } "0xC004F019" { $errorMessage = "The requested event ID is invalid." } "0xC004F01A" { $errorMessage = "The requested event is not registered with the service." } "0xC004F01B" { $errorMessage = "Event ID is already registered." } "0xC004F01C" { $errorMessage = "License is not installed." } "0xC004F01D" { $errorMessage = "Verification of the licence failed." } "0xC004F01E" { $errorMessage = "The input data type does not match the data type in the licence." } "0xC004F01F" { $errorMessage = "The licence is invalid." } "0xC004F020" { $errorMessage = "The licence package is invalid." } "0xC004F021" { $errorMessage = "Validity allowance of the licence has expired." } "0xC004F022" { $errorMessage = "License authorisation failed." } "0xC004F023" { $errorMessage = "License is invalid." } "0xC004F024" { $errorMessage = "License is invalid." } "0xC004F025" { $errorMessage = "Action requires administrator privilege." } "0xC004F026" { $errorMessage = "Required data is not found." } "0xC004F027" { $errorMessage = "License is tampered." } "0xC004F028" { $errorMessage = "Policy cache is invalid." } "0xC004F029" { $errorMessage = "The Software Licensing Service cannot be started in the current OS mode." } "0xC004F02A" { $errorMessage = "License is invalid." } "0xC004F02C" { $errorMessage = "Format for the offline activation data is incorrect." } "0xC004F02D" { $errorMessage = "The version of the offline Confirmation ID is incorrect." } "0xC004F02E" { $errorMessage = "The version of the offline Confirmation ID is not supported." } "0xC004F02F" { $errorMessage = "Length of the offline Confirmation ID is incorrect." } "0xC004F030" { $errorMessage = "The Installation ID or the Confirmation ID could not been saved." } "0xC004F031" { $errorMessage = "The Installation ID and the Confirmation ID do not match." } "0xC004F032" { $errorMessage = "The binding data is invalid. Possible SLIC and Certificate does not match." } "0xC004F033" { $errorMessage = "Product key is not allowed to be installed. Please see the eventlog for details." } "0xC004F034" { $errorMessage = "License not found/invalid or could not connect to the Activation Server." } "0xC004F035" { $errorMessage = "Volume License requires upgrading from a qualified OS or there is a ACPI Table problem." } "0xC004F038" { $errorMessage = "The count reported by your Key Management Service {KMS} is insufficient." } "0xC004F039" { $errorMessage = "The Key Management Service {KMS} is not enabled." } "0xC004F040" { $errorMessage = "Computer was activated but the owner should verify the Product Use Rights." } "0xC004F041" { $errorMessage = "The Key Management Service {KMS} is not activated. KMS needs to be activated." } "0xC004F042" { $errorMessage = "The specified Key Management Service {KMS} cannot be used." } "0xC004F047" { $errorMessage = "Proxy policy has not been updated." } "0xC004F04D" { $errorMessage = "The Installation ID {IID} or the Confirmation ID {CID} is invalid." } "0xC004F04F" { $errorMessage = "License management information was not found in the licences stored." } "0xC004F050" { $errorMessage = "Product key is invalid." } "0xC004F051" { $errorMessage = "Product key is blocked." } "0xC004F052" { $errorMessage = "Licenses contain duplicated properties." } "0xC004F053" { $errorMessage = "The licence contains an override policy that is not configured properly." } "0xC004F054" { $errorMessage = "License management information has duplicated data." } "0xC004F055" { $errorMessage = "Base SKU is not available." } "0xC004F056" { $errorMessage = "The Volume Product detected could not be activated using the Key Management Service {KMS}." } "0xC004F057" { $errorMessage = "Missing a required licence/invalid ACPI entry within the BIOS's SLIC or MSDM Table {1}." } "0xC004F058" { $errorMessage = "Missing a required licence/invalid ACPI entry within the BIOS's SLIC or MSDM Table {2}." } "0xC004F059" { $errorMessage = "The SLIC or MSDM license/ACPI table within the BIOS is invalid." } "0xC004F060" { $errorMessage = "The version of the licence package is invalid." } "0xC004F061" { $errorMessage = "This specified product key can only be used for upgrading, not for clean installations." } "0xC004F062" { $errorMessage = "Required licence could not be found." } "0xC004F063" { $errorMessage = "The system is missing a required OEM licence component, {ACPI Table/Key/Certificate etc}." } "0xC004F064" { $errorMessage = "Non-genuine grace allowance has expired {type 1}." } "0xC004F065" { $errorMessage = "Windows Activation Tools has determined that the system is not genuine. Non Genuine Grace." } "0xC004F066" { $errorMessage = "Genuine information property cannot be set before dependent property has been set." } "0xC004F067" { $errorMessage = "Non-genuine grace allowance has expired {type 2}." } "0xC004F068" { $errorMessage = "Running within the valid non-genuine grace allowance {type 2}." } "0xC004F069" { $errorMessage = "The Software Licensing Service reported that the product SKU is not found." } "0xC004F06A" { $errorMessage = "The requested operation is not allowed." } "0xC004F06B" { $errorMessage = "Virtual machine detected. The Key Management Service {KMS} is not supported in this mode." } "0xC004F06C" { $errorMessage = "The system time on the client computer is too different from the time on the KMS host." } "0xC004F071" { $errorMessage = "Plug-in manifest file is incorrect." } "0xC004F072" { $errorMessage = "License policies for fast query could not be found." } "0xC004F073" { $errorMessage = "License policies for fast query have not been loaded." } "0xC004F074" { $errorMessage = "KMS could not be contacted. Check for Antivirus/Firewall blocking or if time is different." } "0xC004F075" { $errorMessage = "Operation cannot be completed because the service is stopping." } "0xC004F076" { $errorMessage = "Requested plug-in cannot be found." } "0xC004F077" { $errorMessage = "The Software Licensing Service determined incompatible version of authentication data." } "0xC004F078" { $errorMessage = "Key is mismatched." } "0xC004F079" { $errorMessage = "Authentication data is not set." } "0xC004F07A" { $errorMessage = "Verification could not be done." } "0xC004F07B" { $errorMessage = "The requested operation is unavailable while the Software Licensing Service is running." } "0xC004F07C" { $errorMessage = "The version of the computer BIOS is invalid. ACPI Table or other modifications made." } "0xC004F07D" { $errorMessage = "Product key cannot be used for this type of activation." } "0xC004F07E" { $errorMessage = "The Installation ID and the Confirmation ID do not match the product key." } "0xC004F07F" { $errorMessage = "The Installation ID and the Confirmation ID are not bound to the current environment." } "0xC004F080" { $errorMessage = "License is not bound to the current environment. Possible change of main board/components." } "0xC004F081" { $errorMessage = "Active Directory Activation Object could not be found or was invalid." } "0xC004F082" { $errorMessage = "Name specified for the Active Directory Activation Object is too long." } "0xC004F083" { $errorMessage = "Active Directory-Based Activation is not supported in the current Active Directory schema." } "0xC004F200" { $errorMessage = "Current license state is not genuine. Blocked, Blacklisted or MSDN key {not for sale}." } "0xC004F210" { $errorMessage = "The product key does match the computer Edition installed." } "0xC004F211" { $errorMessage = "The hardware of your device has changed. Motherboard, BIOS or other major item replaced." } "0xC004F301" { $errorMessage = "Product could not be activated. The token-based activation challenge has expired." } "0xC004F302" { $errorMessage = "No certificates found in the system that could activate the product." } "0xC004F303" { $errorMessage = "Certificate chain could not be built or failed validation." } "0xC004F304" { $errorMessage = "Required licence could not be found." } "0xC004F305" { $errorMessage = "There are no certificates found in the system that could activate the product." } "0xC004F306" { $errorMessage = "This software edition does not support token-based activation." } "0xC004F307" { $errorMessage = "Activation data is invalid." } "0xC004F308" { $errorMessage = "Activation data has been tampered with." } "0xC004F309" { $errorMessage = "Activation challenge and response do not match." } "0xC004F30A" { $errorMessage = "The certificate does not match the conditions in the licence." } "0xC004F30B" { $errorMessage = "Inserted smartcard could not be used to activate the product." } "0xC004F30C" { $errorMessage = "Token-based activation licence content is invalid." } "0xC004F30D" { $errorMessage = "The thumbprint is invalid." } "0xC004F30E" { $errorMessage = "The thumbprint does not match any certificate." } "0xC004F30F" { $errorMessage = "The certificate does not match the criteria specified in the issuance licence." } "0xC004F310" { $errorMessage = "The certificate does not match the trust point ID specified in the issuance licence." } "0xC004F311" { $errorMessage = "Soft token cannot be used for activation." } "0xC004F312" { $errorMessage = "The certificate cannot be used because its private key is exportable." } "0xC004F313" { $errorMessage = "CNG encryption library could not be loaded." } "0xC004FC03" { $errorMessage = "Networking problem has occurred while activating your copy of Windows." } "0xC004FC04" { $errorMessage = "Running within the timebased validity allowance." } "0xC004FC05" { $errorMessage = "Device has a perpetual grace allowance." } "0xC004FC06" { $errorMessage = "Device is running within the valid extended grace allowance." } "0xC004FC07" { $errorMessage = "Validity allowance has expired." } "0xC004FD00" { $errorMessage = "You've reached the request limit for automatic virtual machine activation." } "0xC004FD01" { $errorMessage = "Windows is not running on a supported Microsoft Hyper-V virtualisation platform." } "0xC004FD02" { $errorMessage = "The parent partition is not activated." } "0xC004FD03" { $errorMessage = "The parent partition cannot activate the guest partition." } "0xC004FD04" { $errorMessage = "Software Licensing reports the computer is not bound to a valid license." } "0xC004FE00" { $errorMessage = "Activation is required to recover from tampering of the Software Licensing trusted store." } "0xC0EA0001" { $errorMessage = "No applicable app licenses found." } "0xC0EA0002" { $errorMessage = "CLiP license not found." } "0xC0EA0003" { $errorMessage = "CLiP device license not found." } "0xC0EA0004" { $errorMessage = "CLiP license has an invalid signature." } "0xC0EA0005" { $errorMessage = "CLiP keyholder license is invalid or missing." } "0xC0EA0006" { $errorMessage = "CLiP license has expired." } "0xC0EA0007" { $errorMessage = "CLiP license is signed by an unknown source." } "0xC0EA0008" { $errorMessage = "CLiP license is not signed." } "0xC0EA0009" { $errorMessage = "CLiP license hardware ID is out of tolerance." } "0xC0EA000A" { $errorMessage = "Hardware has changed beyond tolerance. Device License ID mismatch." } "0xC1900401" { $errorMessage = "Hardware does not permit this build at present, or is not yet available for your device." } "0xD0000272" { $errorMessage = "Activation server is busy or unavailable, cannot connect to server." } "0xFFFFFFFF" { $errorMessage = "Unable to define Status Reason information." } "0x8004FE21" { $errorMessage = "This computer is not running genuine Windows." } "0x80070005" { $errorMessage = "Access denied. Requires elevated privileges." } "0x8007007B" { $errorMessage = "DNS name does not exist." } "0x80070490" { $errorMessage = "The product key you entered did not work." } "0x800706BA" { $errorMessage = "The RPC server is unavailable." } "0x8007232A" { $errorMessage = "DNS server failure." } "0x8007232B" { $errorMessage = "DNS name does not exist." } "0x8007251D" { $errorMessage = "No records found for DNS query." } "0x80092328" { $errorMessage = "DNS name does not exist." } "0xC004B100" { $errorMessage = "The activation server determined that the computer could not be activated." } "0xC004C001" { $errorMessage = "The specified product key is invalid." } "0xC004C003" { $errorMessage = "The specified product key is blocked." } "0xC004C004" { $errorMessage = "The Software Licensing Service reported that the product key is invalid for this Windows edition." } "0xC004C005" { $errorMessage = "The Software Licensing Service reported that the product key is invalid." } "0xC004C006" { $errorMessage = "The Software Licensing Service reported that the product key is in use." } "0xC004C008" { $errorMessage = "The specified product key could not be used." } "0xC004C020" { $errorMessage = "The Multiple Activation Key has exceeded its limit." } "0xC004C021" { $errorMessage = "The MAK extension limit has been exceeded." } "0xC004F001" { $errorMessage = "The Software Licensing Service reported that the license is not installed." } "0xC004F002" { $errorMessage = "The Software Licensing Service reported that the product key is invalid." } "0xC004F003" { $errorMessage = "The Software Licensing Service reported that the license is not activated." } "0xC004F004" { $errorMessage = "The Software Licensing Service reported that the license is expired." } "0xC004F007" { $errorMessage = "The Software Licensing Service reported that the license is corrupt." } "0xC004F009" { $errorMessage = "Grace period expired." } "0xC004F00F" { $errorMessage = "Hardware ID binding is beyond tolerance." } "0xC004F014" { $errorMessage = "The product key is not available." } "0xC004F027" { $errorMessage = "License is expired." } "0xC004F02C" { $errorMessage = "Offline activation data format is incorrect." } "0xC004F035" { $errorMessage = "Cannot activate with a Volume license product key." } "0xC004F038" { $errorMessage = "KMS count insufficient. Cannot activate." } "0xC004F039" { $errorMessage = "KMS is not enabled." } "0xC004F040" { $errorMessage = "KMS could not be contacted." } "0xC004F041" { $errorMessage = "KMS server is not activated." } "0xC004F042" { $errorMessage = "Specified KMS cannot be used." } "0xC004F045" { $errorMessage = "Client activation count is insufficient." } "0xC004F050" { $errorMessage = "Invalid product key." } "0xC004F051" { $errorMessage = "Product key is blocked." } "0xC004F064" { $errorMessage = "Non-genuine grace period expired." } "0xC004F065" { $errorMessage = "Running within valid non-genuine period." } "0xC004F06C" { $errorMessage = "Invalid KMS request timestamp." } "0xC004F074" { $errorMessage = "No KMS server could be contacted." } "0xC004F034" { $errorMessage = "Invalid license. Computer could not be activated." } "0x80072EE7" { $errorMessage = "Server name or address could not be resolved." } "0x8007000E" { $errorMessage = "Not enough memory resources to complete the operation." } "0x80070422" { $errorMessage = "The Software Licensing Service is disabled or stopped." } "0x80070426" { $errorMessage = "The Software Licensing Service reported that the operating system is not licensed." } "0x8007000D" { $errorMessage = "The data is invalid." } "0x80070002" { $errorMessage = "The system cannot find the file specified." } default { if ($slErrors.ContainsKey($uint32Value)) { try { $errorMessage = (($slErrors[$uint32Value] -split ':')[1]).TrimStart() } catch { } } else { $errorMessage = "Unknown error HRESULT $hrHex" } } } return $errorMessage } } <# .SYNOPSIS Opens or closes the global SLC handle, and optionally closes a specified $hSLC handle. #> function Manage-SLHandle { param( [bool]$Close = $false, [IntPtr]$hSLC = [IntPtr]::Zero ) # Initialize global status and handle if they don't exist if (-not $global:Status_) { $global:Status_ = 0 } if (-not $global:hSLC_) { $global:hSLC_ = [IntPtr]::Zero } if (!$Close) { # Open global handle only if not already open if ($global:Status_ -eq 1 -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { Write-Warning "Global handle already open, returning existing handle." return $global:hSLC_ } # Open new handle $global:hSLC_ = [IntPtr]::Zero $hr = $Global:SLC::SLOpen([ref]$global:hSLC_) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } $global:Status_ = 1 return $global:hSLC_ } # Close specific handle if provided and valid if ($hSLC -ne [IntPtr]::Zero -and $hSLC -ne 0) { # Ideally add a tracking system to avoid closing twice Write-Warning "Closing specified handle." $null = $Global:SLC::SLClose($hSLC) return } # Close global handle only if currently open if ($global:Status_ -eq 0) { Write-Warning "Global handle is already closed. No action taken." return } Write-Verbose "Closing global handle." $null = $Global:SLC::SLClose($global:hSLC_) $global:hSLC_ = [IntPtr]::Zero $global:Status_ = 0 } <# typedef enum _tagSLDATATYPE { SL_DATA_NONE = REG_NONE, // 0 SL_DATA_SZ = REG_SZ, // 1 SL_DATA_DWORD = REG_DWORD, // 4 SL_DATA_BINARY = REG_BINARY, // 3 SL_DATA_MULTI_SZ, // 7 SL_DATA_SUM = 100 // 100 } SLDATATYPE; #define REG_NONE 0 /* no type */ #define REG_SZ 1 /* string type (ASCII) */ #define REG_EXPAND_SZ 2 /* string, includes %ENVVAR% (expanded by caller) (ASCII) */ #define REG_BINARY 3 /* binary format, callerspecific */ #define REG_DWORD 4 /* DWORD in little endian format */ #define REG_DWORD_LITTLE_ENDIAN 4 /* DWORD in little endian format */ #define REG_DWORD_BIG_ENDIAN 5 /* DWORD in big endian format */ #define REG_LINK 6 /* symbolic link (UNICODE) */ #define REG_MULTI_SZ 7 /* multiple strings, delimited by \0, terminated by \0\0 (ASCII) */ #define REG_RESOURCE_LIST 8 /* resource list? huh? */ #define REG_FULL_RESOURCE_DESCRIPTOR 9 /* full resource descriptor? huh? */ #define REG_RESOURCE_REQUIREMENTS_LIST 10 #define REG_QWORD 11 /* QWORD in little endian format */ #> # Define the enum-like values in PowerShell $SLDATATYPE = @{ SL_DATA_NONE = 0 # REG_NONE SL_DATA_SZ = 1 # REG_SZ SL_DATA_DWORD = 4 # REG_DWORD SL_DATA_BINARY = 3 # REG_BINARY SL_DATA_MULTI_SZ = 7 # REG_MULTI_SZ SL_DATA_SUM = 100 # Custom value } function Parse-RegistryData { param ( [Parameter(Mandatory=$true)] [int]$dataType, # Data type (e.g., $SLDATATYPE.SL_DATA_NONE, $SLDATATYPE.SL_DATA_SZ, etc.) [Parameter(Mandatory=$true)] [IntPtr]$ptr, # Pointer to the data (e.g., registry value pointer) [Parameter(Mandatory=$true)] [int]$valueSize, # Size of the data (in bytes) [Parameter(Mandatory=$false)] [string]$valueName # Optional, for special cases (e.g., ProductSkuId) ) $result = $null # Default result to null switch ($dataType) { $SLDATATYPE.SL_DATA_NONE { $result = $null } $SLDATATYPE.SL_DATA_SZ { # SL_DATA_SZ = Unicode string # PtrToStringUni expects length in characters, valueSize is in bytes, so divide by 2 $result = [Marshal]::PtrToStringUni($ptr, $valueSize / 2) } $SLDATATYPE.SL_DATA_DWORD { # SL_DATA_DWORD = DWORD (4 bytes) if ($valueSize -ne 4) { $result = $null # Unexpected size, return null } else { $result = [Marshal]::ReadInt32($ptr) } } $SLDATATYPE.SL_DATA_BINARY { # SL_DATA_BINARY = Binary blob if ($valueName -eq 'ProductSkuId' -and $valueSize -eq 16) { # If it's ProductSkuId and the buffer is 16 bytes, treat it as a GUID $bytes = New-Object byte[] 16 [Marshal]::Copy($ptr, $bytes, 0, 16) $result = [Guid]::new($bytes) } elseif ($valueName -eq 'SL_LAST_ACT_ATTEMPT_HRESULT' -and $valueSize -eq 4) { $bytes = New-Object byte[] 4 [Marshal]::Copy($ptr, $bytes, 0, 4) $result = [BitConverter]::ToUInt32($bytes, 0) } elseif ($valueName -match "SL_LAST_ACT_ATTEMPT_TIME|EvaluationEndDate|TrustedTime" -and $valueSize -eq 8) { $bytes = New-Object byte[] 8 [Marshal]::Copy($ptr, $bytes, 0, 8) $fileTime = [BitConverter]::ToInt64($bytes, 0) $result = [DateTime]::FromFileTimeUtc($fileTime) } elseif ($valueName -eq 'SL_LAST_ACT_ATTEMPT_SERVER_FLAGS' -and $valueSize -eq 4) { $bytes = New-Object byte[] 4 [Marshal]::Copy($ptr, $bytes, 0, 4) $result = [BitConverter]::ToUInt32($bytes, 0) } else { # Otherwise, just copy the binary data $result = New-Object byte[] $valueSize [Marshal]::Copy($ptr, $result, 0, $valueSize) } } $SLDATATYPE.SL_DATA_MULTI_SZ { # SL_DATA_MULTI_SZ = Multi-string $raw = [Marshal]::PtrToStringUni($ptr, $valueSize / 2) $result = $raw -split "`0" | Where-Object { $_ -ne '' } } $SLDATATYPE.SL_DATA_SUM { # SL_DATA_SUM = Custom (100) # Handle this case accordingly (based on your logic) $result = $null } default { # Return null for any unsupported data types $result = $null } } return $result } <# .SYNOPSIS $fileId = '?' $LicenseId = '?' $OfficeAppId = '0ff1ce15-a989-479d-af46-f275c6370663' $windowsAppID = '55c92734-d682-4d71-983e-d6ec3f16059f' $enterprisesn = '7103a333-b8c8-49cc-93ce-d37c09687f92' # should return $OfficeAppId & $windowsAppID Write-Warning 'Get all installed application IDs.' Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_APPLICATION Read-Host # should return All Office & windows installed SKU Write-Warning 'Get all installed product SKU IDs.' Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_PRODUCT_SKU Read-Host # should return $SKU per group <Office -or windows> Write-Warning 'Get SKU IDs according to the input application ID.' Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $OfficeAppId Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $windowsAppID Read-Host # should return $windowsAppID or $OfficeAppId Write-Warning 'Get application IDs according to the input SKU ID.' Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_APPLICATION -pQueryId $enterprisesn Read-Host # Same As SLGetInstalledProductKeyIds >> SL_ID_PKEY >> SLGetPKeyInformation >> BLOB Write-Warning 'Get license PKey IDs according to the input SKU ID.' Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_PKEY -pQueryId $enterprisesn Read-Host Write-Warning 'Get license file Ids according to the input SKU ID.' Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_LICENSE_FILE -pQueryId $enterprisesn Read-Host Write-Warning 'Get license IDs according to the input license file ID.' Get-SLIDList -eQueryIdType SL_ID_LICENSE_FILE -eReturnIdType SL_ID_LICENSE -pQueryId $fileId Read-Host Write-Warning 'Get license file ID according to the input license ID.' Get-SLIDList -eQueryIdType SL_ID_LICENSE -pQueryId $LicenseId -eReturnIdType SL_ID_LICENSE_FILE Read-Host Write-Warning 'Get License File Id according to the input License Id' Get-SLIDList -eQueryIdType SL_ID_LICENSE -pQueryId $LicenseId -eReturnIdType SL_ID_LICENSE_FILE Read-Host write-warning "Get union of all application IDs or SKU IDs from all grants of a token activation license." write-warning "Returns SL_E_NOT_SUPPORTED if the license ID is valid but doesn't refer to a token activation license." Get-SLIDList -eQueryIdType SL_ID_LICENSE -pQueryId $LicenseId -eReturnIdType SL_ID_APPLICATION write-warning "Get union of all application IDs or SKU IDs from all grants of a token activation license." write-warning "Returns SL_E_NOT_SUPPORTED if the license ID is valid but doesn't refer to a token activation license." Get-SLIDList -eQueryIdType SL_ID_LICENSE -pQueryId $LicenseId -eReturnIdType SL_ID_PRODUCT_SKU # SLUninstallLicense >> [in] const SLID *pLicenseFileId Write-Warning 'Get License File IDs associated with a specific Application ID:' Get-SLIDList -eQueryIdType SL_ID_APPLICATION -pQueryId $OfficeAppId -eReturnIdType SL_ID_ALL_LICENSE_FILES Read-Host Write-Warning 'Get License File IDs associated with a specific Application ID:' Get-SLIDList -eQueryIdType SL_ID_APPLICATION -pQueryId $OfficeAppId -eReturnIdType SL_ID_ALL_LICENSES Read-Host $LicensingProducts = ( Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $windowsAppID | ? { Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY } ) | % { [PSCustomObject]@{ ID = $_ Description = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Description' Name = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'productName' LicenseFamily = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Family' } } #> enum eQueryIdType { SL_ID_APPLICATION = 0 SL_ID_PRODUCT_SKU = 1 SL_ID_LICENSE_FILE = 2 SL_ID_LICENSE = 3 } enum eReturnIdType { SL_ID_APPLICATION = 0 SL_ID_PRODUCT_SKU = 1 SL_ID_LICENSE_FILE = 2 SL_ID_LICENSE = 3 SL_ID_PKEY = 4 SL_ID_ALL_LICENSES = 5 SL_ID_ALL_LICENSE_FILES = 6 } function Get-SLIDList { param( [Parameter(Mandatory=$true)] [ValidateSet("SL_ID_APPLICATION", "SL_ID_PRODUCT_SKU", "SL_ID_LICENSE_FILE", "SL_ID_LICENSE")] [string]$eQueryIdType, [Parameter(Mandatory=$true)] [ValidateSet("SL_ID_APPLICATION", "SL_ID_PRODUCT_SKU", "SL_ID_LICENSE", "SL_ID_PKEY", "SL_ID_ALL_LICENSES", "SL_ID_ALL_LICENSE_FILES", "SL_ID_LICENSE_FILE")] [string]$eReturnIdType, [Parameter(Mandatory=$false)] [ValidateNotNullOrEmpty()] [string]$pQueryId = $null, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) $dummyGuid = [Guid]::Empty # Validate if pQueryId is required when source and target differ $QueryIdValidation = ($eQueryIdType -ne $eReturnIdType) -and [string]::IsNullOrWhiteSpace($pQueryId) # Validate pQueryId if provided: must be valid non-empty GUID $GuidValidation = (-not [string]::IsNullOrWhiteSpace($pQueryId)) -and ( -not [Guid]::TryParse($pQueryId, [ref]$dummyGuid) -or ($dummyGuid -eq [Guid]::Empty) ) # _ALL_ types allowed only with SL_ID_APPLICATION (ensure string comparison) $AppIDValidation = ($eQueryIdType -ne [eQueryIdType]::SL_ID_APPLICATION) -and ($eReturnIdType.ToString() -match '_ALL_') # When source is SL_ID_APPLICATION and target differs, pQueryId must be a known GUID $AppGUIDValidation = ($eQueryIdType -eq [eQueryIdType]::SL_ID_APPLICATION) -and ($eReturnIdType -ne $eQueryIdType) -and (-not ($knownAppGuids -contains $pQueryId)) if ($AppIDValidation -or $QueryIdValidation -or $GuidValidation -or $AppGUIDValidation) { Write-Warning "Invalid parameters:" if ($AppIDValidation) { " - _ALL_ types are allowed only with SL_ID_APPLICATION" return } if ($QueryIdValidation -and $GuidValidation) { " - A valid, non-empty pQueryId is required when source and target types differ" return } if ($QueryIdValidation -and $AppGUIDValidation) { # Attempt with known Application GUIDs # CASE OF -> Get-SLIDList -eQueryIdType SL_ID_APPLICATION if ($eQueryIdType -eq [eQueryIdType]::SL_ID_APPLICATION) { try { # Trying with each known GUID in the list $output = foreach ($appId in $Global:knownAppGuids) { Get-SLIDList -eQueryIdType $eQueryIdType -eReturnIdType $eReturnIdType -pQueryId $appId } } catch { # Log the error and provide feedback Write-Warning "An error occurred while attempting to retrieve results with known GUIDs: $_" } if ($output) { # Return only GUIDs from the output return $output.Guid } else { Write-Warning "No valid results returned for the known Application GUIDs." return } } # Case: pQueryId is not a valid known GUID when source is SL_ID_APPLICATION and target differs Write-Warning " - pQueryId must be a known Application GUID when source is SL_ID_APPLICATION and target differs" return } if ($QueryIdValidation) { " - A valid pQueryId is required when source and target types differ" return } if ($GuidValidation) { " - pQueryId must be a non-empty valid GUID" return } if ($AppGUIDValidation) { " - pQueryId must match a known Application GUID when source is SL_ID_APPLICATION and target differs" return } } # Convert the enum string to integer values # (Ensure eQueryIdType and eReturnIdType enums are defined globally, e.g., via Add-Type) $eQueryIdTypeInt = [eQueryIdType]::$eQueryIdType $eReturnIdTypeInt = [eReturnIdType]::$eReturnIdType # Initialize variables for unmanaged memory and handle management $queryIdPtr = [IntPtr]::Zero $gch = $null $pnReturnIds = 0 $ppReturnIds = [IntPtr]::Zero # Flag to determine if THIS function needs to close the handle. # Assumes true (needs to close) unless an external handle is provided. $needToCloseLocalHandle = $true # The handle this function will use. Defaults to the passed $hSLC. $currentHSLC = if ($hSLC -and $hSLC -ne [IntPtr]::Zero -and $hSLC -ne 0) { $hSLC } elseif ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } try { # --- Handle SLOpen conditionally --- # If no handle was passed (or it was [IntPtr]::Zero), open a new one. if (-not $currentHSLC -or $currentHSLC -eq [IntPtr]::Zero -or $currentHSLC -eq 0) { $hresult = $Global:SLC::SLOpen([ref]$currentHSLC) if ($hresult -ne 0) { $uint32Value = $hresult -band 0xFFFFFFFF $hexString = "0x{0:X8}" -f $uint32Value throw "Failed to open SLC handle. HRESULT: $hexString" } # $needToCloseLocalHandle remains $true, as this function opened it. } else { # An external handle was provided, so this function should NOT close it. $needToCloseLocalHandle = $false } # Prepare the query ID parameter if ($pQueryId) { if ($pQueryId -match '^[{]?[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}[}]?$') { $queryGuid = [Guid]$pQueryId $bytes = $queryGuid.ToByteArray() # Pin the managed byte array for native calls $gch = [GCHandle]::Alloc($bytes, [GCHandleType]::Pinned) $queryIdPtr = $gch.AddrOfPinnedObject() } else { $queryIdPtr = [Marshal]::StringToHGlobalUni($pQueryId) # Allocates unmanaged memory for string } } else { $queryIdPtr = [IntPtr]::Zero } # Call SLGetSLIDList using the $currentHSLC handle $result = $Global:SLC::SLGetSLIDList($currentHSLC, $eQueryIdTypeInt, $queryIdPtr, $eReturnIdTypeInt, [ref]$pnReturnIds, [ref]$ppReturnIds) # Check for success and valid returned IDs if ($result -eq 0 -and $pnReturnIds -gt 0 -and $ppReturnIds -ne [IntPtr]::Zero) { $guidList = @() # Loop through the array of GUIDs foreach ($i in 0..($pnReturnIds - 1)) { $currentPtr = [IntPtr]([Int64]$ppReturnIds + [Int64]16 * $i) $guidBytes = New-Object byte[] 16 [Marshal]::Copy($currentPtr, $guidBytes, 0, 16) $guidList += (New-Object Guid (,$guidBytes)) } return $guidList } else { $uint32Value = $result -band 0xFFFFFFFF $hexString = "0x{0:X8}" -f $uint32Value # Use Write-Warning and return empty array for common "not found" errors, # otherwise throw a more severe error. if ($result -eq 0xC004F012) { # SL_E_PRODUCT_SKU_NOT_INSTALLED / SL_E_LICENSE_NOT_FOUND return @() } else { throw "Failed to retrieve ID list. HRESULT: $hexString" } } } catch { # Catch and re-throw, providing context to the higher-level caller Write-Warning "Error in Get-SLIDList (QueryIdType: $($eQueryIdType), ReturnIdType: $($eReturnIdType), pQueryId: $($pQueryId)): $($_.Exception.Message)" throw $_ # Re-throw the original error } finally { # --- Memory Cleanup --- if ($ppReturnIds -ne [IntPtr]::Zero) { $null = $Global:kernel32::LocalFree($ppReturnIds) $ppReturnIds = [IntPtr]::Zero } if ($queryIdPtr -ne [IntPtr]::Zero -and $gch -eq $null) { [Marshal]::FreeHGlobal($queryIdPtr) $queryIdPtr = [IntPtr]::Zero } if ($gch -ne $null -and $gch.IsAllocated) { $gch.Free() $gch = $null } # --- SLC Handle Cleanup --- # Close the SLC handle ONLY if this function opened it AND it's a valid non-zero handle. if ($needToCloseLocalHandle -and $currentHSLC -ne [IntPtr]::Zero) { $null = $Global:SLC::SLClose($currentHSLC) $currentHSLC = [IntPtr]::Zero } } } <# .SYNOPSIS Function Retrieve-SKUInfo retrieves related licensing IDs for a given SKU GUID. Also, Support for SL_ID_ALL_LICENSES & SL_ID_ALL_LICENSE_FILES, Only for Application-ID Specific SKUs require particular IDs: - The SKU for SLUninstallLicense requires the ID_LICENSE_FILE GUID. - The SKU for SLUninstallProofOfPurchase requires the ID_PKEY GUID. Optional Pointer: Handle to the Software Licensing Service (SLC). Optional eReturnIdType: Type of ID to return (e.g., SL_ID_APPLICATION, SL_ID_PKEY, etc.). #> function Retrieve-SKUInfo { param( [Parameter(Mandatory = $true)] [ValidatePattern('^[{]?[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}[}]?$')] [string]$SkuId, [Parameter(Mandatory = $false)] [ValidateSet("SL_ID_APPLICATION", "SL_ID_PRODUCT_SKU", "SL_ID_LICENSE", "SL_ID_PKEY", "SL_ID_ALL_LICENSES", "SL_ID_ALL_LICENSE_FILES", "SL_ID_LICENSE_FILE")] [string]$eReturnIdType, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) # Define once at the top $Is__ALL = $eReturnIdType -match '_ALL_' $IsAppID = $Global:knownAppGuids -contains $SkuId # XOR Case, Check if Both Valid, if one valid, exit if ($Is__ALL -xor $IsAppID) { Write-Warning "ApplicationID Work with SL_ID_ALL_LICENSES -or SL_ID_ALL_LICENSE_FILES Only!" return $null } function Get-IDs { param ( [string]$returnType, [Intptr]$hSLC ) try { if ($IsAppID) { return Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType $returnType -pQueryId $SkuId -hSLC $hSLC } else { return Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType $returnType -pQueryId $SkuId -hSLC $hSLC } } catch { Write-Warning "Get-SLIDList call failed for $returnType and $SkuId" return $null } } $product = [Guid]$SkuId if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } try { # [SL_ID_LICENSE_FILE] Case [Guid]$fileId = try { [Guid]::Parse((Get-LicenseDetails -ActConfigId $product -pwszValueName fileId -hSLC $hSLC).Trim().Substring(0,36)) } catch { [GUID]::Empty } # [SL_ID_LICENSE] Case **Alternative** [Guid]$licenseId = try { [Guid]::Parse((Get-LicenseDetails -ActConfigId $product -pwszValueName licenseId -hSLC $hSLC).Trim().Substring(0,36)) } catch { [Guid]::Empty } [Guid]$privateCertificateId = try { [Guid]::Parse((Get-LicenseDetails -ActConfigId $product -pwszValueName privateCertificateId -hSLC $hSLC).Trim().Substring(0,36)) } catch { [Guid]::Empty } # [SL_ID_APPLICATION] Case **Alternative** [Guid]$applicationId = try { [Guid]::Parse((Get-LicenseDetails -ActConfigId $product -pwszValueName applicationId -hSLC $hSLC).Trim().Substring(0,36)) } catch { [Guid]::Empty } # [SL_ID_PKEY] Case **Alternative** [Guid]$pkId = try { [Guid]::Parse((Get-LicenseDetails -ActConfigId $product -pwszValueName pkeyId -hSLC $hSLC).Trim().Substring(0,36)) } catch { [Guid]::Empty } [uint32]$countRef = 0 [IntPtr]$ppKeyIds = [intPtr]::Zero [GUID]$Product_SKU_ID = [GUID]::Empty [uint32]$hresults = $Global:SLC::SLGetInstalledProductKeyIds($hSLC, [ref]$product, [ref]$countRef, [ref]$ppKeyIds) if ($hresults -and ($hresults -eq 0)) { if ($countRef -gt 0 -and ( $ppKeyIds -ne [IntPtr]::Zero)) { if ($ppKeyIds.ToInt64() -gt 0) { try { $buffer = New-Object byte[] 16 [Marshal]::Copy($ppKeyIds, $buffer, 0, 16) $Product_SKU_ID = [Guid]::new($buffer) } catch { $Product_SKU_ID = $null } } } } # ------------------------------------------------- if (-not $eReturnIdType) { $SKU_DATA = [pscustomobject]@{ ID_SKU = $SkuId ID_APPLICATION = if ($applicationId -and $applicationId -ne [Guid]::Empty) { $applicationId } else { try { Get-IDs SL_ID_APPLICATION -hSLC $hSLC } catch { [Guid]::Empty } } ID_PKEY = if ($pkId -and $pkId -ne [Guid]::Empty) { $pkId } elseif ($Product_SKU_ID -and $Product_SKU_ID -ne [Guid]::Empty) { $Product_SKU_ID } else { try { Get-IDs SL_ID_PKEY -hSLC $hSLC } catch { [Guid]::Empty } } ID_LICENSE_FILE = if ($fileId -and $fileId -ne [Guid]::Empty) { $fileId } else { try { Get-IDs SL_ID_LICENSE_FILE -hSLC $hSLC } catch { [Guid]::Empty } } ID_LICENSE = if (($licenseId -and $privateCertificateId) -and ($licenseId -ne [Guid]::Empty -and $privateCertificateId -ne [Guid]::Empty)) { @($licenseId, $privateCertificateId) } else { try { Get-IDs SL_ID_LICENSE -hSLC $hSLC } catch { [Guid]::Empty } } } return $SKU_DATA } switch ($eReturnIdType) { "SL_ID_APPLICATION" { if ($applicationId -and $applicationId -ne [Guid]::Empty) { return $applicationId } try { return Get-IDs SL_ID_APPLICATION -hSLC $hSLC } catch {} return [Guid]::Empty } "SL_ID_PRODUCT_SKU" { return $SkuId } "SL_ID_LICENSE" { if ($licenseId -and $privateCertificateId -and $licenseId -ne [Guid]::Empty -and $privateCertificateId -ne [Guid]::Empty) { return @($licenseId, $privateCertificateId) } try { return Get-IDs SL_ID_LICENSE -hSLC $hSLC } catch {} return [Guid]::Empty } "SL_ID_PKEY" { if ($pkId -and $pkId -ne [Guid]::Empty) { return $pkId } if ($Product_SKU_ID -and $Product_SKU_ID -ne [Guid]::Empty) { return $Product_SKU_ID } try { return Get-IDs SL_ID_PKEY -hSLC $hSLC } catch {} return [Guid]::Empty } "SL_ID_ALL_LICENSES" { try { return Get-IDs SL_ID_ALL_LICENSES -hSLC $hSLC } catch {} return [Guid]::Empty } "SL_ID_ALL_LICENSE_FILES" { try { return Get-IDs SL_ID_ALL_LICENSE_FILES -hSLC $hSLC } catch {} return [Guid]::Empty } "SL_ID_LICENSE_FILE" { if ($fileId -and $fileId -ne [Guid]::Empty) { return $fileId } #try { return Get-IDs SL_ID_LICENSE_FILE -hSLC $hSLC } catch {} return [Guid]::Empty } default { return [Guid]::Empty } } } finally { if ($null -ne $ppKeyIds -and ( $ppKeyIds -ne [IntPtr]::Zero) -and ( $ppKeyIds -ne 0)) { $null = $Global:kernel32::LocalFree($ppKeyIds) } if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } } <# .SYNOPSIS Function Retrieve-SKUInfo retrieves related licensing IDs for a given SKU GUID. Convert option, CD-KEY->Ref/ID, Ref->SKU, SKU->Ref #> function Retrieve-ProductKeyInfo { param ( [ValidateScript({ $_ -ne $null -and $_ -ne [guid]::Empty })] [guid]$SkuId, [ValidateScript({ $_ -ne $null -and $_ -gt 0 })] [int]$RefGroupId, [ValidateScript({ $_ -match '^(?i)[A-Z0-9]{5}(-[A-Z0-9]{5}){4}$' })] [string]$CdKey ) # Validate only one parameter $paramsProvided = @($SkuId, $RefGroupId, $CdKey) | Where-Object { $_ } if ($paramsProvided.Count -ne 1) { Write-Warning "Please specify exactly one of -SkuId, -RefGroupId, or -CdKey" return $null } # SkuId to RefGroupId if ($SkuId) { $entry = $Global:PKeyDatabase | Where-Object { $_.ActConfigId -eq "{$SkuId}" } | Select-Object -First 1 if ($entry) { return $entry.RefGroupId } else { Write-Warning "RefGroupId not found for SkuId: $SkuId" return $null } } # RefGroupId to SkuId elseif ($RefGroupId) { $entry = $Global:PKeyDatabase | Where-Object { $_.RefGroupId -eq $RefGroupId } | Select-Object -First 1 if ($entry) { return [guid]($entry.ActConfigId -replace '[{}]', '') } else { Write-Warning "ActConfigId not found for RefGroupId: $RefGroupId" return $null } } # CdKey to RefGroupId to SkuId elseif ($CdKey) { try { $decoded = KeyDecode -key0 $CdKey.Substring(0,29) $refGroupFromKey = [int]$decoded[2].Value $entry = $Global:PKeyDatabase | Where-Object { $_.RefGroupId -eq $refGroupFromKey } | Select-Object -First 1 if ($entry) { return [PSCustomObject]@{ RefGroupId = $refGroupFromKey SkuId = [guid]($entry.ActConfigId -replace '[{}]', '') } } else { Write-Warning "SKU not found for RefGroupId $refGroupFromKey extracted from CD Key" return $null } } catch { Write-Warning "Failed to decode CD Key: $_" return $null } } } <# .SYNOPSIS Fires a licensing state change event after installing or removing a license/key. #> function Fire-LicensingStateChangeEvent { param ( [Parameter(Mandatory=$true)] [IntPtr]$hSLC ) if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } $SlEvent = "msft:rm/event/licensingstatechanged" $WindowsSlid = New-Object Guid($Global:windowsAppID) $OfficeSlid = New-Object Guid($Global:OfficeAppId) ($WindowsSlid, $OfficeSlid) | % { $hrEvent = $Global:SLC::SLFireEvent( $hSLC, # Using the IntPtr (acting like a pointer) $SlEvent, [ref]$_ ) # Check if the event firing was successful (HRESULT 0 means success) if ($hrEvent -eq 0) { Write-Host "Licensing state change event fired successfully." } else { Write-Host "Failed to fire licensing state change event. HRESULT: $hrEvent" } } if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } }
Main SL Function -- Function [2/2] Update at 21-06-2025 Code: - Update Get-LicenseInfo, Add more information to extract. Code: <# .SYNOPSIS Re-Arm Specific ID <> SKU. #> Function SL-ReArm { param ( [Parameter(Mandatory=$false)] [ValidateSet( '0ff1ce15-a989-479d-af46-f275c6370663', '55c92734-d682-4d71-983e-d6ec3f16059f' )] [GUID]$AppID, [Parameter(Mandatory=$false)] [GUID]$skuID, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { } try { if (-not $AppID -or -not $skuID) { $hrsults = $Global:slc::SLReArmWindows() } elseif ($AppID -and $skuID) { $AppID_ = [GUID]::new($AppID) $skuID_ = [GUID]::new($skuID) $hrsults = $Global:slc::SLReArm( $hSLC, [ref]$AppID_, [REF]$skuID_, 0) } if ($hrsults -ne 0) { $uint32Value = $hrsults -band 0xFFFFFFFF $hexString = "0x{0:X8}" -f $uint32Value if ($slErrors.ContainsKey($uint32Value)) { Write-Warning "Error $($hexString): $($slErrors[$uint32Value])" } else { Write-Warning "Unknown error HRESULT $hexString" } } return $hrsults } finally { if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } } <# .SYNOPSIS Activate Specific SKU. #> Function SL-Activate { param ( [Parameter(Mandatory=$true)] [GUID]$skuID, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { } try { $skuID_ = [GUID]::new($skuID) $hrsults = $Global:slc::SLActivateProduct( $hSLC, [REF]$skuID_, 0,[IntPtr]::Zero,[IntPtr]::Zero,$null,0) if ($hrsults -ne 0) { $uint32Value = $hrsults -band 0xFFFFFFFF $hexString = "0x{0:X8}" -f $uint32Value if ($slErrors.ContainsKey($uint32Value)) { Write-Warning "Error $($hexString): $($slErrors[$uint32Value])" } else { Write-Warning "Unknown error HRESULT $hexString" } } return $hrsults } finally { if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } } <# .SYNOPSIS WMI -> RefreshLicenseStatus #> Function SL-RefreshLicenseStatus { param ( [Parameter(Mandatory=$false)] [ValidateSet( '0ff1ce15-a989-479d-af46-f275c6370663', '55c92734-d682-4d71-983e-d6ec3f16059f' )] [GUID]$AppID, [Parameter(Mandatory=$false)] [GUID]$skuID, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { } try { if (-not $AppID -or -not $skuID) { $hrsults = $Global:slc::SLConsumeWindowsRight($hSLC) } elseif ($AppID -and $skuID) { $AppID_ = [GUID]::new($AppID) $skuID_ = [GUID]::new($skuID) $hrsults = $Global:slc::SLConsumeRight( $hSLC, [ref]$AppID_, [REF]$skuID_, [IntPtr]::Zero,[IntPtr]::Zero) } if ($hrsults -ne 0) { $uint32Value = $hrsults -band 0xFFFFFFFF $hexString = "0x{0:X8}" -f $uint32Value if ($slErrors.ContainsKey($uint32Value)) { Write-Warning "Error $($hexString): $($slErrors[$uint32Value])" } else { Write-Warning "Unknown error HRESULT $hexString" } } return $hrsults } finally { if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } } <# .SYNOPSIS Usage: KEY SL-InstallProductKey -Keys "3HYJN-9KG99-F8VG9-V3DT8-JFMHV" SL-InstallProductKey -Keys ("BW9HJ-N9HF7-7M9PW-3PBJR-37DCT","NJ8QJ-PYYXJ-F6HVQ-RYPFK-BKQ86","K8BH4-6TN3G-YXVMY-HBMMF-KBXPT","GMN9H-QCX29-F3JWJ-RYPKC-DDD86","TN6YY-MWHCT-T6PK2-886FF-6RBJ6") #> function SL-InstallProductKey { param ( [Parameter(Mandatory = $true)] [string[]]$Keys, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } [guid[]]$PKeyIdLst = @() # Store the GUIDs of successfully installed keys try { # Validate the Keys parameter if (-not $Keys) { Write-Warning "No product keys provided. Please provide at least one key." return $null } # Check for invalid keys (empty, null, or whitespace) $invalidKeys = $Keys | Where-Object { [string]::IsNullOrWhiteSpace($_) } if ($invalidKeys.Count -gt 0) { Write-Warning "The following keys are invalid (empty or whitespace): $($invalidKeys -join ', ')" return $null } # Loop through each provided key foreach ($key in $Keys) { # Prepare the KeyBlob (if required by the API) $KeyBlob = [System.Text.Encoding]::UTF8.GetBytes($key) # Convert product key string to byte array # Try multiple key types (order of preference) $KeyTypes = @( "msft:rm/algorithm/pkey/2009", "msft:rm/algorithm/pkey/2007", "msft:rm/algorithm/pkey/2005" ) # Attempt installation with different KeyTypes $PKeyIdOut = [Guid]::NewGuid() $installationSuccess = $false # Flag to track installation success for each key foreach ($KeyType in $KeyTypes) { # Call the SLInstallProofOfPurchase API with the current key type $hrInstall = $Global:SLC::SLInstallProofOfPurchase( $hSLC, $KeyType, $key, # Directly using the key string 0, # PKeyDataSize is 0 (no additional data) [IntPtr]::Zero, # No additional data (zero pointer) [ref]$PKeyIdOut ) # Check if the installation was successful (HRESULT 0 means success) if ($hrInstall -eq 0) { Write-Host "Proof of purchase installed successfully with KeyType: $KeyType. PKeyId: $PKeyIdOut" $PKeyIdLst += $PKeyIdOut # Add the successful GUID to the list $installationSuccess = $true # Mark success for this key break # Exit the loop as soon as the installation is successful } } # If the installation failed after all attempts, log an error if (-not $installationSuccess) { $uint32Value = $hrInstall -band 0xFFFFFFFF $hexString = "0x{0:X8}" -f $uint32Value if ($slErrors.ContainsKey($uint32Value)) { Write-Warning "Error $($hexString): $($slErrors[$uint32Value])" } else { Write-Warning "Unknown error HRESULT $hexString" } Write-Warning "Failed to install the proof of purchase for key $key. HRESULT: $hrInstall" } } } finally { # Trigger licensing state change event Fire-LicensingStateChangeEvent -hSLC $hSLC if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } # Return list of successfully installed PKeyIds #return $PKeyIdLst } <# .SYNOPSIS Usage: KEY -OR SKU -OR PKEY Usage: Remove Current Windows KEY Example. SL-UninstallProductKey -ClearKey $true SL-UninstallProductKey -KeyLst ("3HYJN-9KG99-F8VG9-V3DT8-JFMHV", "JFMHV") -skuList @("dabaa1f2-109b-496d-bf49-1536cc862900") -pkeyList @("e953e4ac-7ce5-0401-e56c-70c13b8e5a82") #> function SL-UninstallProductKey { param ( [Parameter(Mandatory = $false)] [string[]]$KeyLst, # List of partial product keys (optional) [Parameter(Mandatory = $false)] [GUID[]]$skuList, # List of GUIDs (optional) [Parameter(Mandatory = $false)] [GUID[]]$pkeyList, # List of GUIDs (optional), [bool]$ClearKey, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } try { # Initialize the list to hold GUIDs $guidList = @() if (-not ($skuList -or $KeyLst -or $pkeyList) -and !$ClearKey) { Write-Warning "No provided SKU or Key" return } $validSkuList = @() $validCdKeys = @() $validPkeyList = @() if ($KeyLst) { foreach ($key in $KeyLst) { # Accept 29-char full CD keys or 5-char partials if ($key.Length -eq 29) { $validCdKeys += $key.Substring(24, 5) # Take last 5 chars } elseif ($key.Length -eq 5) { $validCdKeys += $key }}} if ($skuList) { foreach ($sku in $skuList) { if ($sku -match '^[{]?[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}[}]?$') { $validSkuList += [guid]$sku }}} if ($pkeyList) { foreach ($pkey in $pkeyList) { if ($pkey -match '^[{]?[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}[}]?$') { $validPkeyList += [guid]$pkey }}} $results = @() foreach ($guid in ( Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_PRODUCT_SKU)) { $ID_PKEY = Retrieve-SKUInfo -SkuId $guid -eReturnIdType SL_ID_PKEY if ($ID_PKEY) { $results += [PSCustomObject]@{ SL_ID_PRODUCT_SKU = $guid SL_ID_PKEY = $ID_PKEY PartialProductKey = Get-SLCPKeyInfo -PKEY $ID_PKEY -pwszValueName PartialProductKey } } } # Initialize filtered results array $filteredResults = @() foreach ($item in $results) { $isValidPkey = $validPkeyList -contains $item.SL_ID_PKEY $isValidKey = $validCdKeys -contains $item.PartialProductKey $isValidSKU = $validSkuList -contains $item.SL_ID_PRODUCT_SKU if ($isValidKey){ write-warning "Valid key found, $($item.PartialProductKey)" } if ($isValidSKU){ write-warning "Valid SKU found, $($item.SL_ID_PRODUCT_SKU)" } if ($isValidPkey){ write-warning "Valid PKEY found, $($item.SL_ID_PKEY)" } if ($isValidKey -or $isValidSKU -or $isValidPkey) { $filteredResults += $item } } # Step 3: Retrieve unique SL_ID_PKEY values from the filtered results $SL_ID_PKEY_list = $filteredResults | Select-Object -ExpandProperty SL_ID_PKEY | Sort-Object | Select-Object -Unique if ($ClearKey) { $pPKeyId = [GUID]::Empty $AlgoTypes = @( "msft:rm/algorithm/pkey/2009", "msft:rm/algorithm/pkey/2007", "msft:rm/algorithm/pkey/2005" ) $DigitalKey = $(Parse-DigitalProductId).DigitalKey if (-not $DigitalKey) { $DigitalKey = $(Parse-DigitalProductId4).DigitalKey } if ($DigitalKey) { foreach ($type in $AlgoTypes) { $hresults = $Global:SLC::SLGetPKeyId( $hSLC,$type,$DigitalKey,[Intptr]::Zero,[Intptr]::Zero,[ref]$pPKeyId) if ($hresults -eq 0) { break; } } if ($hresults -eq 0 -and ( $pPKeyId -ne [GUID]::Empty)) { $SL_ID_PKEY_list = @($pPKeyId) } } } # Proceed to uninstall each product key using its GUID foreach ($guid in $SL_ID_PKEY_list) { if ($guid) { Write-Host "Attempting to uninstall product key with GUID: $guid" $hrUninstall = $Global:SLC::SLUninstallProofOfPurchase($hSLC, $guid) if ($hrUninstall -eq 0) { Write-Host "Product key uninstalled successfully: $guid" } else { $uint32Value = $hrUninstall -band 0xFFFFFFFF $hexString = "0x{0:X8}" -f $uint32Value Write-Warning "Failed to uninstall product key with HRESULT: $hexString for GUID: $guid" } } else { Write-Warning "Skipping invalid GUID: $guid" } } } catch { Write-Warning "An unexpected error occurred: $_" } finally { # Launch event of license status change after license/key install/remove Fire-LicensingStateChangeEvent -hSLC $hSLC if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } } <# .SYNOPSIS # Path to license file $licensePath = 'C:\Program Files\Microsoft Office\root\Licenses16\client-issuance-bridge-office.xrm-ms' if (-not (Test-Path $licensePath)) { Write-Warning "License file not found: $licensePath" return } # 1. Install license from file path (string) Write-Host "`n--- Installing from file path ---" $result1 = SL-InstallLicense -LicenseInput $licensePath Write-Host "Result (file path): $result1`n" # 2. Install license from byte array Write-Host "--- Installing from byte array ---" $bytes = [System.IO.File]::ReadAllBytes($licensePath) $result2 = SL-InstallLicense -LicenseInput $bytes Write-Host "Result (byte array): $result2`n" # 3. Install license from text string Write-Host "--- Installing from text string ---" $licenseText = Get-Content $licensePath -Raw $result3 = SL-InstallLicense -LicenseInput $licenseText Write-Host "Result (text): $result3`n" #> function SL-InstallLicense { param ( # Can be string (file path or raw text) or byte[] [Parameter(Mandatory = $true)] [object[]]$LicenseInput, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) # Prepare to install license $LicenseFileIdOut = [Guid]::NewGuid() # Store the file IDs for all successfully installed licenses $LicenseFileIds = @() if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } try { # Initialize an array to store blobs $LicenseBlobs = @() # Loop through each license input foreach ($input in $LicenseInput) { # Determine the type of input and process accordingly if ($input -is [byte[]]) { # If input is already a byte array, use it directly $LicenseBlob = $input } elseif ($input -is [string]) { if (Test-Path $input) { # If it's a file path, read the file and get its byte array $LicenseBlob = [File]::ReadAllBytes($input) } else { # If it's plain text, convert the text to a byte array $LicenseBlob = [Encoding]::UTF8.GetBytes($input) } } else { Write-Warning "Invalid input type. Provide a file path, byte array, or text string." continue } if ($LicenseBlob) { # Pin the current blob in memory $blobPtr = [Marshal]::UnsafeAddrOfPinnedArrayElement($LicenseBlob, 0) # Call the installation API for the current LicenseBlob $hrInstall = $Global:SLC::SLInstallLicense($hSLC, $LicenseBlob.Length, $blobPtr, [ref]$LicenseFileIdOut) # Check if the installation was successful (HRESULT 0 means success) if ($hrInstall -ne 0) { $uint32Value = $hrInstall -band 0xFFFFFFFF $hexString = "0x{0:X8}" -f $uint32Value if ($slErrors.ContainsKey($uint32Value)) { Write-Warning "Error $($hexString): $($slErrors[$uint32Value])" } else { Write-Warning "Unknown error HRESULT $hexString" } Write-Warning "Failed to install the proof of purchase for key $key. HRESULT: $hrInstall" continue # Skip to the next blob if the current installation fails } # If successful, add the LicenseFileIdOut to the array $LicenseFileIds += $LicenseFileIdOut Write-Host "Successfully installed license with FileId: $LicenseFileIdOut" } } } finally { # Launch event of license status change after license/key install/remove Fire-LicensingStateChangeEvent -hSLC $hSLC if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } # Return all the File IDs that were successfully installed #return $LicenseFileIds } <# .SYNOPSIS Uninstalls the license specified by the license file ID and target user option. By --> SL_ID_ALL_LICENSE_FILES $OfficeAppId = '0ff1ce15-a989-479d-af46-f275c6370663' $SL_ID_List = Get-SLIDList -eQueryIdType SL_ID_APPLICATION -pQueryId $OfficeAppId -eReturnIdType SL_ID_ALL_LICENSE_FILES SL-UninstallLicense -LicenseFileIds $SL_ID_List By --> SL_ID_PRODUCT_SKU --> $OfficeAppId = '0ff1ce15-a989-479d-af46-f275c6370663' $WMI_QUERY = Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $OfficeAppId SL-UninstallLicense -ProductSKUs $WMI_QUERY >>> Results >> ActConfigId ProductDescription ----------- ------------------ {DABAA1F2-109B-496D-BF49-1536CC862900} Office16_O365AppsBasicR_Subscription >>> Command >> SL-UninstallLicense -ProductSKUs ('DABAA1F2-109B-496D-BF49-1536CC862900' -as [GUID]) #> function SL-UninstallLicense { param ( [Parameter(Mandatory=$false)] [Guid[]]$ProductSKUs, [Parameter(Mandatory=$false)] [Guid[]]$LicenseFileIds, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) if (-not $ProductSKUs -and -not $LicenseFileIds) { throw "You must provide at least one of -ProductSKUs or -LicenseFileIds." } if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } try { $LicenseFileIdsLst = @() # Add valid LicenseFileIds directly if ($LicenseFileIds) { foreach ($lfid in $LicenseFileIds) { if ($lfid -is [Guid]) { $LicenseFileIdsLst += $lfid }}} # Convert each ProductSKU to LicenseFileId and add it if ($ProductSKUs) { foreach ($sku in $ProductSKUs) { if ($sku -isnot [Guid]) { continue } $fileGuid = Retrieve-SKUInfo -SkuId $sku -eReturnIdType SL_ID_LICENSE_FILE -hSLC $hSLC if ($fileGuid -and ($fileGuid -is [Guid]) -and ($fileGuid -ne [Guid]::Empty)) { $LicenseFileIdsLst += $fileGuid }}} foreach ($LicenseFileId in ($LicenseFileIdsLst | Sort-Object -Unique)) { $hresult = $Global:SLC::SLUninstallLicense($hSLC, [ref]$LicenseFileId) if ($hresult -ne 0) { # Convert to unsigned 32-bit int (number) $uint32Value = $hresult -band 0xFFFFFFFF # Format as hex string (for display only) $hexString = "0x{0:X8}" -f $uint32Value # Lookup by integer key (not string) if ($slErrors.ContainsKey($uint32Value)) { Write-Warning "Error $($hexString): $($slErrors[$uint32Value])" } else { Write-Warning "Unknown error HRESULT $hexString" } } else { Write-Warning "License File ID: $LicenseFileId was removed." } } } catch { # Convert to unsigned 32-bit int (number) $hresult = $_.Exception.HResult $uint32Value = $hresult -band 0xFFFFFFFF # Format as hex string (for display only) $hexString = "0x{0:X8}" -f $uint32Value # Lookup by integer key (not string) if ($slErrors.ContainsKey($uint32Value)) { Write-Warning "Error $($hexString): $($slErrors[$uint32Value])" } else { Write-Warning "Unknown error HRESULT $hexString" } } finally { # Launch event of license status change after license/key install/remove Fire-LicensingStateChangeEvent -hSLC $hSLC if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } } <# .SYNOPSIS Retrieves Software Licensing Client status for application and product SkuID. Example: $LicensingProducts = ( Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $windowsAppID | ? { Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY } ) | % { [PSCustomObject]@{ ID = $_ PKEY = Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY Description = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Description' Name = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'productName' LicenseFamily = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Family' } } Clear-Host $LicensingProducts | % { Write-Host Write-Warning "Get-SLCPKeyInfo Function" Get-SLCPKeyInfo -PKEY ($_).PKEY -loopAllValues $true Write-Host Write-Warning "Get-SLLicensingStatus" Get-SLLicensingStatus -ApplicationID 55c92734-d682-4d71-983e-d6ec3f16059f -SkuID ($_).ID Write-Host Write-Warning "Get-GenuineInformation" Write-Host Get-GenuineInformation -QueryId ($_).ID -loopAllValues $true Write-Host Write-Warning "Get-ApplicationInformation" Write-Host Get-ApplicationInformation -ApplicationId ($_).ID -loopAllValues $true } #> enum LicenseStatusEnum { Unlicensed = 0 Licensed = 1 OOBGrace = 2 OOTGrace = 3 NonGenuineGrace = 4 Notification = 5 ExtendedGrace = 6 } enum LicenseCategory { KMS38 # Valid until 2037–2038 KMS4K # Beyond 2038 ShortTermVL # Volume expiring within 6 months Unknown NonKMS } function Get-SLLicensingStatus { [CmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateSet("55c92734-d682-4d71-983e-d6ec3f16059f", "0ff1ce15-a989-479d-af46-f275c6370663")] [Guid]$ApplicationID, [Parameter(Mandatory=$true)] [ValidateNotNullOrEmpty()] [Guid]$SkuID, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } try { $guidPattern = '^(?im)[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$' if ($SkuID -notmatch $guidPattern) { return $null } $pnStatusCount = [uint32]0 $ppLicensingStatus = [IntPtr]::Zero $pAppID = $ApplicationID $pProductSkuId = $SkuID $result = $global:slc::SLGetLicensingStatusInformation( $hSLC, [ref]$pAppID, [ref]$pProductSkuId, [IntPtr]::Zero, [ref]$pnStatusCount, [ref]$ppLicensingStatus ) $licensingInfo = $null if ($result -eq 0 -and $pnStatusCount -gt 0 -and $ppLicensingStatus -ne [IntPtr]::Zero) { $eStatus = [Marshal]::ReadInt32($ppLicensingStatus, 16) $dwGraceTime = [Marshal]::ReadInt32($ppLicensingStatus, 20) $dwTotalGraceDays = [Marshal]::ReadInt32($ppLicensingStatus, 24) $hrReason = [Marshal]::ReadInt32($ppLicensingStatus, 28) $qwValidityExpiration = [Marshal]::ReadInt64($ppLicensingStatus, 32) if (($null -eq $eStatus) -or ($null -eq $dwGraceTime)) { return $null } $expirationDateTime = $null if ($qwValidityExpiration -gt 0) { try { $expirationDateTime = [DateTime]::FromFileTimeUtc($qwValidityExpiration) } catch {} } $now = Get-Date $graceExpirationDate = $now.AddMinutes($dwGraceTime) $graceUpToYear = $graceExpirationDate.Year $daysLeft = ($graceExpirationDate - $now).Days $year = $graceExpirationDate.Year $licenseCategory = $Global:PKeyDatabase | Where-Object { $_.ActConfigId -eq "{$skuId}" } | Select-Object -First 1 -ExpandProperty ProductKeyType if ($licenseCategory -ieq 'Volume:GVLK') { if ($year -gt 2038) { $typeKMS = [LicenseCategory]::KMS4K } elseif ($year -in 2037, 2038) { $typeKMS = [LicenseCategory]::KMS38 } elseif ($daysLeft -le 180 -and $daysLeft -ge 0) { $typeKMS = [LicenseCategory]::ShortTermVL } else { $typeKMS = [LicenseCategory]::Unknown } } else { $typeKMS = [LicenseCategory]::NonKMS } $errorMessage = Get-WindowsErrorMessage $hrReason $hrHex = '0x{0:X8}' -f ($hrReason -band 0xFFFFFFFF) return [PSCustomObject]@{ ID = $SkuID LicenseStatus = [LicenseStatusEnum]$eStatus GracePeriodRemaining = $dwGraceTime TotalGraceDays = $dwTotalGraceDays EvaluationEndDate = $expirationDateTime LicenseStatusReason = $hrHex LicenseChannel = $licenseCategory LicenseTier = $typeKMS ApiCallHResult = '0x{0:X8}' -f $result ErrorMessege = $errorMessage } } } catch{} finally { if ($ppLicensingStatus -ne [IntPtr]::Zero) { $null = $Global:SLC::SLClose($ppLicensingStatus) $ppLicensingStatus = [IntPtr]::Zero } if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } } <# .SYNOPSIS Gets the information of the specified product key. work for all sku that are activated AKA [SL_ID_PKEY], else, no results. how to receive them --> demo code --> Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_PRODUCT_SKU | ? {Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY} Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_PRODUCT_SKU | ? {Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY} | % { Get-SLCPKeyInfo $_ -loopAllValues $true } Example: $LicensingProducts = ( Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $windowsAppID | ? { Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY } ) | % { [PSCustomObject]@{ ID = $_ PKEY = Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY Description = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Description' Name = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'productName' LicenseFamily = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Family' } } Clear-Host $LicensingProducts | % { Write-Host Write-Warning "Get-SLCPKeyInfo Function" Get-SLCPKeyInfo -PKEY ($_).PKEY -loopAllValues $true Write-Host Write-Warning "Get-SLLicensingStatus" Get-SLLicensingStatus -ApplicationID 55c92734-d682-4d71-983e-d6ec3f16059f -SkuID ($_).ID Write-Host Write-Warning "Get-GenuineInformation" Write-Host Get-GenuineInformation -QueryId ($_).ID -loopAllValues $true Write-Host Write-Warning "Get-ApplicationInformation" Write-Host Get-ApplicationInformation -ApplicationId ($_).ID -loopAllValues $true } #> function Get-SLCPKeyInfo { param( [Parameter(Mandatory = $false)] [Guid] $SKU, [Parameter(Mandatory = $false)] [Guid] $PKEY, [Parameter(Mandatory = $false)] [ValidateSet("DigitalPID", "DigitalPID2", "PartialProductKey", "ProductSkuId", "Channel")] [string] $pwszValueName, [Parameter(Mandatory = $false)] [bool]$loopAllValues = $false, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) # Oppsite XOR Case, Validate it Not both if (!($pwszValueName -xor $loopAllValues)) { Write-Warning "Choice 1 option only, can't use both / none" return } if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } try { # If loopAllValues is true, loop through all values in the ValidateSet and fetch the details for each $allValues = @{} $allValueNames = @("DigitalPID", "DigitalPID2", "PartialProductKey", "ProductSkuId", "Channel" ) foreach ($valueName in $allValueNames) { $allValues[$valueName] = $null } if ($PKEY -and $PKEY -ne [GUID]::Empty) { $PKeyId = $PKEY } elseif ($SKU -and $SKU -ne [GUID]::Empty) { $PKeyId = Retrieve-SKUInfo -SkuId $SKU -eReturnIdType SL_ID_PKEY -hSLC $hSLC } if (-not $PKeyId) { return ([GUID]::Empty) } if ($loopAllValues) { foreach ($valueName in $allValueNames) { $dataType = 0 $bufferSize = 0 $bufferPtr = [IntPtr]::Zero $hr = $Global:SLC::SLGetPKeyInformation( $hSLC, [ref]$PKeyId, $valueName, [ref]$dataType, [ref]$bufferSize, [ref]$bufferPtr ) if ($hr -ne 0) { continue; } $allValues[$valueName] = Parse-RegistryData -dataType $dataType -ptr $bufferPtr -valueSize $bufferSize -valueName $valueName } return $allValues } $dataType = 0 $bufferSize = 0 $bufferPtr = [IntPtr]::Zero $hr = $Global:SLC::SLGetPKeyInformation( $hSLC, [ref]$PKeyId, $pwszValueName, [ref]$dataType, [ref]$bufferSize, [ref]$bufferPtr ) if ($hr -ne 0) { throw "SLGetPKeyInformation failed: HRESULT 0x{0:X8}" -f $hr } return Parse-RegistryData -dataType $dataType -ptr $bufferPtr -valueSize $bufferSize -valueName $pwszValueName } catch { } finally { if ($null -ne $bufferPtr -and ( $bufferPtr -ne [IntPtr]::Zero)) { $null = $Global:kernel32::LocalFree($bufferPtr) } if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } } <# .SYNOPSIS Gets information about the genuine state of a Windows computer. [in] pQueryId A pointer to an SLID structure that specifies the *application* to check. pQueryId pQueryId can be one of the following. ApplicationId in case of querying following property values. SL_PROP_BRT_DATA SL_PROP_BRT_COMMIT SKUId in case of querying following property values. SL_PROP_LAST_ACT_ATTEMPT_HRESULT SL_PROP_LAST_ACT_ATTEMPT_TIME SL_PROP_LAST_ACT_ATTEMPT_SERVER_FLAGS SL_PROP_ACTIVATION_VALIDATION_IN_PROGRESS Example: $LicensingProducts = ( Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $windowsAppID | ? { Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY } ) | % { [PSCustomObject]@{ ID = $_ PKEY = Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY Description = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Description' Name = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'productName' LicenseFamily = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Family' } } Clear-Host $LicensingProducts | % { Write-Host Write-Warning "Get-SLCPKeyInfo Function" Get-SLCPKeyInfo -PKEY ($_).PKEY -loopAllValues $true Write-Host Write-Warning "Get-SLLicensingStatus" Get-SLLicensingStatus -ApplicationID 55c92734-d682-4d71-983e-d6ec3f16059f -SkuID ($_).ID Write-Host Write-Warning "Get-GenuineInformation" Write-Host Get-GenuineInformation -QueryId ($_).ID -loopAllValues $true Write-Host Write-Warning "Get-ApplicationInformation" Write-Host Get-ApplicationInformation -ApplicationId ($_).ID -loopAllValues $true } #> function Get-GenuineInformation { param ( [Parameter(Mandatory)] [string]$QueryId, [Parameter(Mandatory=$false)] [ValidateSet( 'SL_BRT_DATA', 'SL_BRT_COMMIT', 'SL_LAST_ACT_ATTEMPT_TIME', 'SL_LAST_ACT_ATTEMPT_HRESULT', 'SL_LAST_ACT_ATTEMPT_SERVER_FLAGS', 'SL_ACTIVATION_VALIDATION_IN_PROGRESS' )] [string]$ValueName, [Parameter(Mandatory = $false)] [bool]$loopAllValues = $false, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) # Oppsite XOR Case, Validate it Not both if (!($ValueName -xor $loopAllValues)) { Write-Warning "Choice 1 option only, can't use both / none" return } # Cast ApplicationId to Guid $appGuid = [Guid]::Parse($QueryId) $IsAppID = $Global:knownAppGuids -contains $appGuid if ($IsAppID -and (-not $loopAllValues) -and ($ValueName -notmatch '_BRT_')) { Write-Warning "The selected property '$ValueName' is not valid for an ApplicationId." return } elseif ((-not $IsAppID) -and (-not $loopAllValues) -and ($ValueName -match '_BRT_')) { Write-Warning "The selected property '$ValueName' is not valid for a SKUId." return } if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } # Prepare variables for out params $dataType = 0 $valueSize = 0 $ptrValue = [IntPtr]::Zero if ($loopAllValues) { # Combine all arrays and remove duplicates $allValues = @{} $allValueNames = if ($IsAppID) { @( 'SL_BRT_DATA', 'SL_BRT_COMMIT' ) } else { @( 'SL_LAST_ACT_ATTEMPT_HRESULT', 'SL_LAST_ACT_ATTEMPT_TIME', 'SL_LAST_ACT_ATTEMPT_SERVER_FLAGS', 'SL_ACTIVATION_VALIDATION_IN_PROGRESS' ) } foreach ($Name in $allValueNames) { # Clear value $allValues[$Name] = $null $dataType = 0 $valueSize = 0 $hresult = $global:SLC::SLGetGenuineInformation( [ref] $appGuid, $Name, [ref] $dataType, [ref] $valueSize, [ref] $ptrValue ) if ($hresult -ne 0) { continue } if ($valueSize -eq 0 -or $ptrValue -eq [IntPtr]::Zero) { continue } $allValues[$Name] = Parse-RegistryData -dataType $dataType -ptr $ptrValue -valueSize $valueSize -valueName $Name if ($allValues[$Name] -and ( $Name -eq 'SL_LAST_ACT_ATTEMPT_HRESULT')) { $hrReason = $allValues[$Name] $errorMessage = Get-WindowsErrorMessage $hrReason $hrHex = '0x{0:X8}' -f ($hrReason -band 0xFFFFFFFF) $allValues[$Name] = $hrHex } } if ($errorMessage) { $allValues.Add("SL_LAST_ACT_ATTEMPT_MESSEGE",$errorMessage) } return $allValues } try { # Call SLGetGenuineInformation - pass [ref] for out params $hresult = $global:SLC::SLGetGenuineInformation( [ref] $appGuid, $ValueName, [ref] $dataType, [ref] $valueSize, [ref] $ptrValue ) if ($hresult -ne 0) { # Convert to unsigned 32-bit int (number) $uint32Value = $hresult -band 0xFFFFFFFF # Format as hex string (for display only) $hexString = "0x{0:X8}" -f $uint32Value # Lookup by integer key (not string) if ($slErrors.ContainsKey($uint32Value)) { Write-Warning "Error $($hexString): $($slErrors[$uint32Value])" } else { Write-Warning "Unknown error HRESULT $hexString" } throw "SLGetGenuineInformation failed with HRESULT: $res" } if ($valueSize -eq 0 -or $ptrValue -eq [IntPtr]::Zero) { return $null } # Example function or context where the data type is being checked return Parse-RegistryData -dataType $dataType -ptr $ptrValue -valueSize $valueSize -valueName $ValueName } finally { # Free memory allocated by SLGetGenuineInformation if ($ptrValue -ne [IntPtr]::Zero) { $null = $global:kernel32::LocalFree($ptrValue) } if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } } } <# .SYNOPSIS Gets information about the specified application. Example: $LicensingProducts = ( Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $windowsAppID | ? { Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY } ) | % { [PSCustomObject]@{ ID = $_ PKEY = Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY Description = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Description' Name = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'productName' LicenseFamily = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Family' } } Clear-Host $LicensingProducts | % { Write-Host Write-Warning "Get-SLCPKeyInfo Function" Get-SLCPKeyInfo -PKEY ($_).PKEY -loopAllValues $true Write-Host Write-Warning "Get-SLLicensingStatus" Get-SLLicensingStatus -ApplicationID 55c92734-d682-4d71-983e-d6ec3f16059f -SkuID ($_).ID Write-Host Write-Warning "Get-GenuineInformation" Write-Host Get-GenuineInformation -QueryId ($_).ID -loopAllValues $true Write-Host Write-Warning "Get-ApplicationInformation" Write-Host Get-ApplicationInformation -ApplicationId ($_).ID -loopAllValues $true } #> function Get-ApplicationInformation { param ( [Parameter(Mandatory)] [string]$ApplicationId, [Parameter(Mandatory = $false)] [ValidateSet( "IsKeyManagementService", "KeyManagementServiceCurrentCount", "KeyManagementServiceRequiredClientCount", "KeyManagementServiceUnlicensedRequests", "KeyManagementServiceLicensedRequests", "KeyManagementServiceOOBGraceRequests", "KeyManagementServiceOOTGraceRequests", "KeyManagementServiceNonGenuineGraceRequests", "KeyManagementServiceNotificationRequests", "KeyManagementServiceTotalRequests", "KeyManagementServiceFailedRequests" )] [string]$PropertyName, [Parameter(Mandatory = $false)] [bool]$loopAllValues = $false, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) # Oppsite XOR Case, Validate it Not both if (!($PropertyName -xor $loopAllValues)) { Write-Warning "Choice 1 option only, can't use both / none" return } # Cast ApplicationId to Guid $appGuid = [Guid]$ApplicationId if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } if ($loopAllValues) { # Combine all arrays and remove duplicates $allValues = @{} $allValueNames = ("IsKeyManagementService", "KeyManagementServiceCurrentCount", "KeyManagementServiceRequiredClientCount", "KeyManagementServiceUnlicensedRequests", "KeyManagementServiceLicensedRequests", "KeyManagementServiceOOBGraceRequests", "KeyManagementServiceOOTGraceRequests", "KeyManagementServiceNonGenuineGraceRequests", "KeyManagementServiceNotificationRequests", "KeyManagementServiceTotalRequests", "KeyManagementServiceFailedRequests") # Allocate memory for dataType (optional out parameter) $dataTypePtr = [Marshal]::AllocHGlobal(4) # Allocate memory for valueSize (UINT* out param) $valueSizePtr = [Marshal]::AllocHGlobal(4) # Allocate memory for pointer to byte buffer (PBYTE* out param) $ptrPtr = [Marshal]::AllocHGlobal([IntPtr]::Size) foreach ($valueName in $allValueNames) { # Clear value $allValues[$valueName] = $null # Initialize the out params to zero/null [Marshal]::WriteInt32($dataTypePtr, 0) [Marshal]::WriteInt32($valueSizePtr, 0) [Marshal]::WriteIntPtr($ptrPtr, [IntPtr]::Zero) $res = $global:SLC::SLGetApplicationInformation( $hSLC, [ref]$appGuid, $valueName, $dataTypePtr, $valueSizePtr, $ptrPtr ) if ($res -ne 0) { continue } # Read the outputs from the unmanaged memory pointers $dataType = [Marshal]::ReadInt32($dataTypePtr) $valueSize = [Marshal]::ReadInt32($valueSizePtr) # Dereference the pointer-to-pointer to get actual buffer pointer $ptr = [Marshal]::ReadIntPtr($ptrPtr) if ($ptr -eq [IntPtr]::Zero) { continue } if ($valueSize -eq 0) { continue } $allValues[$valueName] = Parse-RegistryData -dataType $dataType -ptr $ptr -valueSize $valueSize -valueName $valueName } return $allValues } # Allocate memory for dataType (optional out parameter) $dataTypePtr = [Marshal]::AllocHGlobal(4) # Allocate memory for valueSize (UINT* out param) $valueSizePtr = [Marshal]::AllocHGlobal(4) # Allocate memory for pointer to byte buffer (PBYTE* out param) $ptrPtr = [Marshal]::AllocHGlobal([IntPtr]::Size) try { # Initialize the out params to zero/null [Marshal]::WriteInt32($dataTypePtr, 0) [Marshal]::WriteInt32($valueSizePtr, 0) [Marshal]::WriteIntPtr($ptrPtr, [IntPtr]::Zero) $res = $global:SLC::SLGetApplicationInformation( $hSLC, [ref]$appGuid, $PropertyName, $dataTypePtr, $valueSizePtr, $ptrPtr ) if ($res -ne 0) { # Convert to unsigned 32-bit int (number) $uint32Value = $res -band 0xFFFFFFFF # Format as hex string (for display only) $hexString = "0x{0:X8}" -f $uint32Value # Lookup by integer key (not string) if ($slErrors.ContainsKey($uint32Value)) { Write-Warning "Error $($hexString): $($slErrors[$uint32Value])" } else { Write-Warning "Unknown error HRESULT $hexString" } throw "SLGetApplicationInformation failed (code $res)" } # Read the outputs from the unmanaged memory pointers $dataType = [Marshal]::ReadInt32($dataTypePtr) $valueSize = [Marshal]::ReadInt32($valueSizePtr) # Dereference the pointer-to-pointer to get actual buffer pointer $ptr = [Marshal]::ReadIntPtr($ptrPtr) if ($ptr -eq [IntPtr]::Zero) { throw "Pointer to data buffer is null" } if ($valueSize -eq 0) { throw "Returned value size is zero" } return Parse-RegistryData -dataType $dataType -ptr $ptr -valueSize $valueSize -valueName $PropertyName } finally { # Free the memory allocated for the out parameters if ($ptr -and $ptr -ne [IntPtr]::Zero) { $null = $global:kernel32::LocalFree($ptr) } if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } if ($dataTypePtr -and $dataTypePtr -ne [IntPtr]::Zero) { [Marshal]::FreeHGlobal($dataTypePtr) } if ($valueSizePtr -and $valueSizePtr -ne [IntPtr]::Zero) { [Marshal]::FreeHGlobal($valueSizePtr) } if ($ptrPtr -and $ptrPtr -ne [IntPtr]::Zero) { [Marshal]::FreeHGlobal($ptrPtr) } } } <# .SYNOPSIS Gets information about the specified product SKU. "Description", "Name", "Author", Taken from Microsoft Offical Documentation. # ---------------------------------------------- fileId # SL_ID_LICENSE_FILE pkeyId # SL_ID_PKEY productSkuId # SL_ID_PRODUCT_SKU applicationId # SL_ID_APPLICATION licenseId # SL_ID_LICENSE privateCertificateId # SL_ID_LICENSE # ------>>>> More info ------>>> https://github.com/LBBNetwork/openredpill/blob/master/slpublic.h https://learn.microsoft.com/en-us/windows/win32/api/slpublic/nf-slpublic-slgetslidlist SL_ID_APPLICATION, appId X SL_ID_PRODUCT_SKU, skuId ? SL_ID_LICENSE_FILE, fileId V SL_ID_LICENSE, LicenseId V # ---------------------------------------------- "msft:sl/EUL/GENERIC/PUBLIC", "msft:sl/EUL/GENERIC/PRIVATE", "msft:sl/EUL/PHONE/PUBLIC", "msft:sl/EUL/PHONE/PRIVATE", "msft:sl/EUL/STORE/PUBLIC", "msft:sl/EUL/STORE/PRIVATE", # ---------------------------------------------- Now found that it read --> r:otherInfo Section So it support for Any <tm:infoStr name= <r:otherInfo xmlns:r="urn:mpeg:mpeg21:2003:01-REL-R-NS"> <tm:infoTables xmlns:tm="http://www.microsoft.com/DRM/XrML2/TM/v2"> <tm:infoList tag="#global"> <tm:infoStr name="licenseType">msft:sl/PL/GENERIC/PUBLIC</tm:infoStr> <tm:infoStr name="licenseVersion">2.0</tm:infoStr> <tm:infoStr name="licensorUrl">http://licensing.microsoft.com</tm:infoStr> <tm:infoStr name="licenseCategory">msft:sl/PL/GENERIC/PUBLIC</tm:infoStr> <tm:infoStr name="productSkuId">{2c060131-0e43-4e01-adc1-cf5ad1100da8}</tm:infoStr> <tm:infoStr name="privateCertificateId">{274ff0e9-dfec-43e7-b675-67e61645b6a9}</tm:infoStr> <tm:infoStr name="applicationId">{55c92734-d682-4d71-983e-d6ec3f16059f}</tm:infoStr> <tm:infoStr name="productName">Windows(R), EnterpriseSN edition</tm:infoStr> <tm:infoStr name="Family">EnterpriseSN</tm:infoStr> <tm:infoStr name="productAuthor">Microsoft Corporation</tm:infoStr> <tm:infoStr name="productDescription">Windows(R) Operating System</tm:infoStr> <tm:infoStr name="clientIssuanceCertificateId">{4961cc30-d690-43be-910c-8e2db01fc5ad}</tm:infoStr> <tm:infoStr name="hwid:ootGrace">0</tm:infoStr> </tm:infoList> </tm:infoTables> </r:otherInfo> <r:otherInfo xmlns:r="urn:mpeg:mpeg21:2003:01-REL-R-NS"> <tm:infoTables xmlns:tm="http://www.microsoft.com/DRM/XrML2/TM/v2"> <tm:infoList tag="#global"> <tm:infoStr name="licenseType">msft:sl/PL/GENERIC/PRIVATE</tm:infoStr> <tm:infoStr name="licenseVersion">2.0</tm:infoStr> <tm:infoStr name="licensorUrl">http://licensing.microsoft.com</tm:infoStr> <tm:infoStr name="licenseCategory">msft:sl/PL/GENERIC/PRIVATE</tm:infoStr> <tm:infoStr name="publicCertificateId">{0f6421d2-b7ea-45e0-b87d-773975685c35}</tm:infoStr> <tm:infoStr name="clientIssuanceCertificateId">{4961cc30-d690-43be-910c-8e2db01fc5ad}</tm:infoStr> <tm:infoStr name="hwid:ootGrace">0</tm:infoStr> <tm:infoStr name="win:branding">126</tm:infoStr> </tm:infoList> </tm:infoTables> </r:otherInfo> #> <# Cls $WMI_QUERY = Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_PRODUCT_SKU $XML_Table = $WMI_QUERY | % { Get-LicenseDetails $_ -ReturnRawData $true} write-host $uniqueNamesHashTable = @{} foreach ($xmlEntry in $XML_Table) { # Ensure the licenseGroup property exists on the current object if ($xmlEntry.licenseGroup) { # The 'license' property within licenseGroup can be a single object or an array of objects. # Use @() to ensure it's treated as an array, making iteration consistent. foreach ($licenseObject in @($xmlEntry.licenseGroup.license)) { # Safely navigate the object path to get to the 'infoStr' elements. # We check each step to prevent errors if a property is missing. if ($licenseObject.otherInfo -and $licenseObject.otherInfo.infoTables -and $licenseObject.otherInfo.infoTables.infoList -and $licenseObject.otherInfo.infoTables.infoList.infoStr) { # Extract all 'name' attributes from the 'infoStr' elements for the current license. # If infoStr is a single object, .name will work. If it's an array, it will automatically # collect all names. $names = $licenseObject.otherInfo.infoTables.infoList.infoStr.name # Add each extracted name to our hashtable. # The 'ContainsKey' check ensures that only unique names are added. foreach ($name in @($names)) { # @($names) ensures we iterate even if $names is a single string if (-not $uniqueNamesHashTable.ContainsKey($name)) { $uniqueNamesHashTable[$name] = $true # Value can be anything; we only care about the key } } } } } } $uniqueNamesHashTable.keys $xmlStrings = $XML_Table | ForEach-Object { $_.OuterXml } $regexPattern = ">(msft.*?)<" $extractedContent = New-Object System.Collections.ArrayList # Use ArrayList for efficient adding foreach ($xmlString in $xmlStrings) { $matchesInCurrentString = [regex]::Matches($xmlString, $regexPattern) if ($matchesInCurrentString.Count -gt 0) { foreach ($match in $matchesInCurrentString) { # Add the content of the first capturing group (index 1) to our ArrayList # $match.Groups[0] would be the entire match (>msft...<) # $match.Groups[1] is the content of the first capturing group (msft...) [void]$extractedContent.Add($match.Groups[1].Value) } } } write-host if ($extractedContent.Count -gt 0) { $extractedContent | Select-Object -Unique | Sort-Object | ForEach-Object { Write-Host $_ }} Read-Host #> function Get-LicenseDetails { param ( [Parameter(Mandatory)] [Guid]$ActConfigId, [Parameter(Mandatory = $false)] [ValidateSet( "fileId", "pkeyId", "productSkuId", "applicationId", "licenseId", "privateCertificateId", "msft:sl/EUL/GENERIC/PUBLIC", "msft:sl/EUL/GENERIC/PRIVATE", "msft:sl/EUL/PHONE/PUBLIC", "msft:sl/EUL/PHONE/PRIVATE", "msft:sl/EUL/STORE/PUBLIC", "msft:sl/EUL/STORE/PRIVATE", "Description", "Name", "Author", "TokenActivationILID", "TokenActivationILVID","TokenActivationGrantNumber", "TokenActivationCertificateThumbprint", "TokenActivationAdditionalInfo", "pkeyConfigLicenseId", "licenseType", "licenseVersion", "licensorUrl", "productName", "Family", "productAuthor", "productDescription", "licenseCategory", "hwid:ootGrace", "issuanceCertificateId", "ValUrl", "PAUrl", "ActivationSequence", "UXDifferentiator", "ProductKeyGroupUniqueness", "EnableNotificationMode", "EULURL", "GraceTimerUniqueness", "ValidityTimerUniqueness", "EnableActivationValidation", "DependsOn", "phone:policy", "licensorKeyIndex", "BuildVersion", "ValidationTemplateId", "ProductUniquenessGroupId", "ApplicationBitmap", "migratable", "ProductKeyID", "VLActivationInterval", "VLRenewalInterval", "KeyManagementServiceProductKeyID", "KeyManagementServicePort", "TrustedTime", "CustomerPID", "KeyManagementServiceName", "KeyManagementServicePort", "DiscoveredKeyManagementServiceName", "DiscoveredKeyManagementServicePort", "TimeBasedExtendedGrace" )] [String]$pwszValueName, [Parameter(Mandatory = $false)] [bool]$loopAllValues = $false, [Parameter(Mandatory = $false)] [bool]$ReturnRawData = $false, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) # 3 CASES OF XOR if (@([BOOL]$pwszValueName + [BOOL]$loopAllValues + [BOOL]$ReturnRawData) -ne 1) { Write-Warning "Exactly one of -pwszValueName, -loopAllValues, or -ReturnRawData must be specified." return } if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } try { if ($loopAllValues) { $allValues = @{} $SL_ID = @( "fileId", # SL_ID_LICENSE_FILE "pkeyId", # SL_ID_PKEY "productSkuId", # SL_ID_PRODUCT_SKU "applicationId" # SL_ID_APPLICATION "licenseId", # SL_ID_LICENSE "privateCertificateId" # SL_ID_LICENSE ) # un offical, intersting pattern # first saw in MAS AIO file, TSforge project} $MSFT = @( "msft:sl/EUL/GENERIC/PUBLIC", "msft:sl/EUL/GENERIC/PRIVATE", # un-offical "msft:sl/EUL/PHONE/PUBLIC", "msft:sl/EUL/PHONE/PRIVATE", # un-offical "msft:sl/EUL/STORE/PUBLIC", "msft:sl/EUL/STORE/PRIVATE" # un-offical ) # Offical from MS $OfficalPattern = @("Description", "Name", "Author") # the rest, from XML Blobs --> <infoStr> $xml = @("pkeyConfigLicenseId", "privateCertificateId", "licenseType", "licensorUrl", "licenseCategory", "productName", "Family","licenseVersion", "productAuthor", "productDescription", "hwid:ootGrace", "issuanceCertificateId", "PAUrl", "ActivationSequence", "ValidationTemplateId", "ValUrl", "UXDifferentiator", "ProductKeyGroupUniqueness", "EnableNotificationMode", "GraceTimerUniqueness", "ValidityTimerUniqueness", "EnableActivationValidation", "DependsOn", "phone:policy", "licensorKeyIndex", "BuildVersion", "ProductUniquenessGroupId", "ApplicationBitmap", "migratable") # SoftwareLicensingProduct class (WMI) $SoftwareLicensingProduct = @( "Name", "Description", "ApplicationID", "VLActivationInterval", "VLRenewalInterval", "ProductKeyID", "KeyManagementServiceProductKeyID", "KeyManagementServicePort", "RequiredClientCount", "TrustedTime", "TokenActivationILID", "TokenActivationILVID", "TokenActivationGrantNumber", "TokenActivationCertificateThumbprint", "CustomerPID", "TokenActivationAdditionalInfo", "KeyManagementServiceName", "KeyManagementServicePort", "DiscoveredKeyManagementServiceName", "DiscoveredKeyManagementServicePort", "TimeBasedExtendedGrace", "EULURL" ) # Combine all arrays and remove duplicates $allValueNames = ($SL_ID + $MSFT + $OfficalPattern + $xml + $SoftwareLicensingProduct) | Sort-Object -Unique foreach ($valueName in $allValueNames) { $dataType = 0 $valueSize = 0 $ptr = [IntPtr]::Zero $res = $global:SLC::SLGetProductSkuInformation( $hSLC, [ref]$ActConfigId, $valueName, [ref]$dataType, [ref]$valueSize, [ref]$ptr ) if ($res -ne 0) { #Write-Warning "fail to process Name: $valueName" $allValues[$valueName] = $null continue; } $allValues[$valueName] = Parse-RegistryData -dataType $dataType -ptr $ptr -valueSize $valueSize -valueName $valueName } return $allValues } if ($pwszValueName) { $dataType = 0 $valueSize = 0 $ptr = [IntPtr]::Zero $res = $global:SLC::SLGetProductSkuInformation( $hSLC, [ref]$ActConfigId, $pwszValueName, [ref]$dataType, [ref]$valueSize, [ref]$ptr ) if ($res -ne 0) { #$messege = $(Get-WindowsErrorMessage -ErrorCode $res) #Write-Warning "ERROR $res, $messege, Value: $pwszValueName" throw } # Parse value based on data type return Parse-RegistryData -dataType $dataType -ptr $ptr -valueSize $valueSize -valueName $pwszValueName } # Get FileId string for the SKU $fileGuid = Retrieve-SKUInfo -SkuId $ActConfigId -eReturnIdType SL_ID_LICENSE_FILE -hSLC $hSLC if (-not $fileGuid -or ( [guid]$fileGuid -eq [GUID]::Empty)) { return $null } # Get license XML blob $count = 0 $ptr = [IntPtr]::Zero $res = $global:SLC::SLGetLicense($hSLC, [ref]$fileGuid, [ref]$count, [ref]$ptr) if ($res -ne 0) { throw "SLGetLicense failed (code $res)" } $blob = New-Object byte[] $count [Marshal]::Copy($ptr, $blob, 0, $count) $content = [Text.Encoding]::UTF8.GetString($blob) $xmlContent = $content.Substring($content.IndexOf('<r')) $xml = [xml]$xmlContent if ($ReturnRawData) { return $xml } # Transform into detailed custom objects $licenseObjects = @() foreach ($license in $xml.licenseGroup.license) { $policyList = @() foreach ($policy in $license.grant.allConditions.allConditions.productPolicies.policyStr) { $policyList += [PSCustomObject]@{ Name = $policy.name Value = $policy.InnerText } } if (-not $policyList) { continue; } $licenseObjects += [PSCustomObject]@{ LicenseId = $license.licenseId GrantName = $license.grant.name Policies = $policyList } } return $licenseObjects } catch { } finally { if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } if ($null -ne $ptr -and ( $ptr -ne [IntPtr]::Zero)) { $null = $global:kernel32::LocalFree($ptr) } } } <# class SoftwareLicensingProduct { string ID; --> Function * SLGetProductSkuInformation --> productSkuId string Name; --> Function * SLGetProductSkuInformation string Description; --> Function * SLGetProductSkuInformation string ApplicationID; --> Function * SLGetProductSkuInformation string ProcessorURL; --> Function * SLGetProductSkuInformation string MachineURL; --> Function * SLGetProductSkuInformation string ProductKeyURL; --> Function * SLGetProductSkuInformation string UseLicenseURL; --> Function * SLGetProductSkuInformation --> PAUrl [-or EULURL, By abbody1406] uint32 LicenseStatus; --> Function * SLGetLicensingStatusInformation uint32 LicenseStatusReason; --> Function * SLGetLicensingStatusInformation uint32 GracePeriodRemaining; --> Function * SLGetLicensingStatusInformation datetime EvaluationEndDate; --> Function * SLGetLicensingStatusInformation string OfflineInstallationId; --> Function * SLGenerateOfflineInstallationId string PartialProductKey; --> Function * SLGetPKeyInformation string ProductKeyID; --> Function * SLGetPKeyInformation string ProductKeyID2; --> Function * SLGetPKeyInformation string ProductKeyChannel; --> Function * SLGetPKeyInformation string LicenseFamily; --> Function * SLGetProductSkuInformation --> Family string LicenseDependsOn; --> Function * SLGetProductSkuInformation --> DependsOn string ValidationURL; --> Function * SLGetProductSkuInformation --> ValUrl boolean LicenseIsAddon; --> Function * SLGetProductSkuInformation --> [BOOL](DependsOn) uint32 VLActivationInterval; --> Function * SLGetProductSkuInformation uint32 VLRenewalInterval; --> Function * SLGetProductSkuInformation string KeyManagementServiceProductKeyID; --> Function * SLGetProductSkuInformation --> CustomerPID string KeyManagementServiceMachine; --> Function * SLGetProductSkuInformation --> KeyManagementServiceName uint32 KeyManagementServicePort; --> Function * SLGetProductSkuInformation --> KeyManagementServicePort string DiscoveredKeyManagementServiceMachineName; --> Function * SLGetProductSkuInformation --> DiscoveredKeyManagementServiceName uint32 DiscoveredKeyManagementServiceMachinePort; --> Function * SLGetProductSkuInformation --> DiscoveredKeyManagementServicePort BOOL IsKeyManagementServiceMachine; --> Function * SLGetApplicationInformation --> Key: "IsKeyManagementService" (SL_INFO_KEY_IS_KMS) uint32 KeyManagementServiceCurrentCount; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceCurrentCount" (SL_INFO_KEY_KMS_CURRENT_COUNT) uint32 RequiredClientCount; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceRequiredClientCount" (SL_INFO_KEY_KMS_REQUIRED_CLIENT_COUNT) uint32 KeyManagementServiceUnlicensedRequests; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceUnlicensedRequests" (SL_INFO_KEY_KMS_UNLICENSED_REQUESTS) uint32 KeyManagementServiceLicensedRequests; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceLicensedRequests" (SL_INFO_KEY_KMS_LICENSED_REQUESTS) uint32 KeyManagementServiceOOBGraceRequests; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceOOBGraceRequests" (SL_INFO_KEY_KMS_OOB_GRACE_REQUESTS) uint32 KeyManagementServiceOOTGraceRequests; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceOOTGraceRequests" (SL_INFO_KEY_KMS_OOT_GRACE_REQUESTS) uint32 KeyManagementServiceNonGenuineGraceRequests; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceNonGenuineGraceRequests" (SL_INFO_KEY_KMS_NON_GENUINE_GRACE_REQUESTS) uint32 KeyManagementServiceTotalRequests; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceTotalRequests" (SL_INFO_KEY_KMS_TOTAL_REQUESTS) uint32 KeyManagementServiceFailedRequests; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceFailedRequests" (SL_INFO_KEY_KMS_FAILED_REQUESTS) uint32 KeyManagementServiceNotificationRequests; --> Function * SLGetApplicationInformation --> Key: "KeyManagementServiceNotificationRequests" (SL_INFO_KEY_KMS_NOTIFICATION_REQUESTS) uint32 GenuineStatus; --> Function * SLGetLicensingStatusInformation uint32 ExtendedGrace; --> Function * SLGetProductSkuInformation --> TimeBasedExtendedGrace string TokenActivationILID; --> Function * SLGetProductSkuInformation uint32 TokenActivationILVID; --> Function * SLGetProductSkuInformation uint32 TokenActivationGrantNumber; --> Function * SLGetProductSkuInformation string TokenActivationCertificateThumbprint; --> Function * SLGetProductSkuInformation string TokenActivationAdditionalInfo; --> Function * SLGetProductSkuInformation datetime TrustedTime; --> Function * SLGetProductSkuInformation }; #> <# .SYNOPSIS Get Info per license, using Pkeyconfig [XML] & low level API $WMI_QUERY = Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_PRODUCT_SKU $WMI_SQL = $WMI_QUERY | % { Get-LicenseInfo -ActConfigId $_ } $WMI_SQL | Select-Object * -ExcludeProperty Policies | ? EditionID -NotMatch 'ESU' Manage-SLHandle -Close $true #> function Get-LicenseInfo { param( [Parameter(Mandatory = $true)] [string] $ActConfigId, [Parameter(Mandatory=$false)] [Intptr]$hSLC = [IntPtr]::Zero ) function Get-BrandingValue { param ( [Parameter(Mandatory=$true)] [guid]$sku, [string]$excludeLicense = 'ESU', [string]$skuQueryId = 'SL_ID_PRODUCT_SKU', [string]$appMatch = '55c92734-d682-4d71-983e-d6ec3f16059f' ) try { # Fetch license details for the SKU $xml = Get-LicenseDetails -ActConfigId $sku -ReturnRawData $true -hSLC $hSLC if (-not $xml) { return; } $BrandingValue = $xml.licenseGroup.license[1].otherInfo.infoTables.infoList.infoStr | Where-Object Name -EQ 'win:branding' return $BrandingValue.'#text' #$match = $Global:productTypeTable | Where-Object { # [Convert]::ToInt32($_.DWORD, 16) -eq $BrandingValue.'#text' #} #return $match.ProductID } catch { Write-Warning "An error occurred: $_" return $null } } Function Get-KeyManagementServiceInfo { param ( [Parameter(Mandatory=$true)] [STRING]$SKU_ID ) if ([STRING]::IsNullOrWhiteSpace($SKU_ID) -or ( $SKU_ID -notmatch '^[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}$')) { Return @(); } $Base = "HKLM:SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform" $Application_ID = Retrieve-SKUInfo -SkuId 7103a333-b8c8-49cc-93ce-d37c09687f92 -eReturnIdType SL_ID_APPLICATION | select -ExpandProperty Guid if ($Application_ID) { $KeyManagementServiceName = Get-ItemProperty -Path "$Base\$Application_ID\$SKU_ID" -Name "KeyManagementServiceName" -ea 0 | select -ExpandProperty KeyManagementServiceName $KeyManagementServicePort = Get-ItemProperty -Path "$Base\$Application_ID\$SKU_ID" -Name "KeyManagementServicePort" -ea 0 | select -ExpandProperty KeyManagementServicePort } if (-not $KeyManagementServiceName) { $KeyManagementServiceName = Get-ItemProperty -Path "$Base" -Name "KeyManagementServiceName" -ea 0 | select -ExpandProperty KeyManagementServiceName } if (-not $KeyManagementServicePort) { $KeyManagementServicePort = Get-ItemProperty -Path "$Base" -Name "KeyManagementServicePort" -ea 0 | select -ExpandProperty KeyManagementServicePort } return @{ KeyManagementServiceName = $KeyManagementServiceName KeyManagementServicePort = $KeyManagementServicePort } } if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hSLC = if ($global:hSLC_ -and $global:hSLC_ -ne [IntPtr]::Zero -and $global:hSLC_ -ne 0) { $global:hSLC_ } else { Manage-SLHandle } } try { $closeHandle = $true if (-not $hSLC -or $hSLC -eq [IntPtr]::Zero -or $hSLC -eq 0) { $hr = $Global:SLC::SLOpen([ref]$hSLC) if ($hr -ne 0) { throw "SLOpen failed: HRESULT 0x{0:X8}" -f $hr } } else { $closeHandle = $false } } catch { return $null } # Normalize GUID (no braces for WMI) $guidNoBraces = $ActConfigId.Trim('{}') # Get WMI data filtered by ID #$wmiData = Get-WmiObject -Query "SELECT * FROM SoftwareLicensingProduct WHERE ID='$guidNoBraces'" $Policies = Get-LicenseDetails -ActConfigId $ActConfigId -hSLC $hSLC if ($Policies) { $policiesArray = foreach ($item in $Policies) { $LicenseId = $item.LicenseId foreach ($policy in $item.Policies) { if ($policy.Name -and $policy.Value) { [PSCustomObject]@{ ID = $LicenseId Name = $policy.Name Value = $policy.Value } } } } } # Gets the information of the specified product key. $SLCPKeyInfo = Get-SLCPKeyInfo -SKU $ActConfigId -loopAllValues $true -hSLC $hSLC # Define your ValidateSet values for license details $info = Get-LicenseDetails -ActConfigId $ActConfigId -loopAllValues $true -hSLC $hSLC if ($null -ne $hSLC -and ( $hSLC -ne [IntPtr]::Zero) -and ( $hSLC -ne 0) -and ( $closeHandle)) { Write-Warning "Consider Open handle Using Manage-SLHandle" $null = $Global:SLC::SLClose($hSLC) } # Extract XML data filtered by ActConfigId $xmlData = $Global:PKeyDatabase | ? { $_.ActConfigId -eq $ActConfigId -or $_.ActConfigId -eq "{$guidNoBraces}" } $KeyManagementServiceInfo = Get-KeyManagementServiceInfo -SKU_ID $ActConfigId $ppwszInstallationId = '' $pProductSkuId = [GUID]::new($ActConfigId) $null = $Global:SLC::SLGenerateOfflineInstallationId($hSLC, [ref]$pProductSkuId, [ref]$ppwszInstallationId) return [PSCustomObject]@{ # Policies Policies = $policiesArray # XML data properties, with safety checks ActConfigId = if ($xmlData.ActConfigId) { $xmlData.ActConfigId } else { $null } RefGroupId = if ($xmlData.RefGroupId) { $xmlData.RefGroupId } else { $null } EditionId = if ($xmlData.EditionId) { $xmlData.EditionId } else { $null } #ProductDescription = if ($xmlData.ProductDescription) { $xmlData.ProductDescription } else { $null } ProductKeyType = if ($xmlData.ProductKeyType) { $xmlData.ProductKeyType } else { $null } IsRandomized = if ($xmlData.IsRandomized) { $xmlData.IsRandomized } else { $null } # License Details (from ValidateSet) Description = $info["Description"] Name = $info["Name"] Author = $info["Author"] licenseType = $info["licenseType"] licenseVersion = $info["licenseVersion"] licensorUrl = $info["licensorUrl"] licenseCategory = $info["licenseCategory"] ID = $info["productSkuId"] privateCertificateId = $info["privateCertificateId"] applicationId = $info["applicationId"] productName = $info["productName"] LicenseFamily = $info["Family"] productAuthor = $info["productAuthor"] productDescription = $info["productDescription"] hwidootGrace = $info["hwid:ootGrace"] TrustedTime = $info["TrustedTime"] ProductUniquenessGroupId = $info["ProductUniquenessGroupId"] issuanceCertificateId = $info["issuanceCertificateId"] pkeyConfigLicenseId = $info["pkeyConfigLicenseId"] ValidationURL = $info["ValUrl"] BuildVersion = $info["BuildVersion"] ActivationSequence = $info["ActivationSequence"] EnableActivationValidation = $info["EnableActivationValidation"] ValidityTimerUniqueness = $info["ValidityTimerUniqueness"] ApplicationBitmap = $info["ApplicationBitmap"] # Abbody1406 suggestion PAUrl -or EULURL UseLicenseURL = if ($info["PAUrl"]) {$info["PAUrl"]} else {if ($info["EULURL"]) {$info["EULURL"]} else {$null}} ExtendedGrace = $info["TimeBasedExtendedGrace"] phone_policy = $info["phone:policy"] UXDifferentiator = $info["UXDifferentiator"] ProductKeyGroupUniqueness = $info["ProductKeyGroupUniqueness"] migratable = $info["migratable"] LicenseDependsOn = $info["DependsOn"] LicenseIsAddon = [BOOL]($info["DependsOn"]) EnableNotificationMode = $info["EnableNotificationMode"] GraceTimerUniqueness = $info["GraceTimerUniqueness"] VLActivationInterval = $info["VLActivationInterval"] ValidationTemplateId = $info["ValidationTemplateId"] licensorKeyIndex = $info["licensorKeyIndex"] TokenActivationILID = $info["TokenActivationILID"] TokenActivationILVID = $info["TokenActivationILVID"] TokenActivationGrantNumber = $info["TokenActivationGrantNumber"] TokenActivationCertificateThumbprint = $info["TokenActivationCertificateThumbprint"] TokenActivationAdditionalInfo = $info["TokenActivationAdditionalInfo"] OfflineInstallationId = $ppwszInstallationId #KeyManagementServicePort = $info["KeyManagementServicePort"] #KeyManagementServiceName = if ($KeyManagementServiceInfo.KeyManagementServiceName) { $KeyManagementServiceInfo.KeyManagementServiceName } else { $null } #KeyManagementServicePort = if ($KeyManagementServiceInfo.KeyManagementServicePort) { $KeyManagementServiceInfo.KeyManagementServicePort } else { $null } # thank's abbody1406 for last 5 item's KeyManagementServiceProductKeyID = $info["CustomerPID"] KeyManagementServiceMachine = $info["KeyManagementServiceName"] KeyManagementServicePort = $info["KeyManagementServicePort"] DiscoveredKeyManagementServiceMachineName = $info["DiscoveredKeyManagementServiceName"] DiscoveredKeyManagementServiceMachinePort = $info["DiscoveredKeyManagementServicePort"] # CPKey Info ProductKeyChannel = $SLCPKeyInfo["Channel"] ProductKeyID = $SLCPKeyInfo["DigitalPID"] ProductKeyID2 = $SLCPKeyInfo["DigitalPID2"] #ProductSkuId = $SLCPKeyInfo["ProductSkuId"] PartialProductKey = $SLCPKeyInfo["PartialProductKey"] } }
Also share here some example's Notice, due to libary update. it might not work, i update it today . to fit all change's. 10/06/2025 Get Info for Active license { * ignore ESU } Code: $LicensingProducts = ( Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $windowsAppID | ? { Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY } ) | % { [PSCustomObject]@{ ID = $_ PKEY = Retrieve-SKUInfo -SkuId $_ -eReturnIdType SL_ID_PKEY Description = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Description' Name = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'productName' LicenseFamily = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Family' } } $LicensingProducts | % { Get-SLCPKeyInfo -PKEY ($_).PKEY -loopAllValues $true } $LicensingProducts | % { Get-SLLicensingStatus -ApplicationID 55c92734-d682-4d71-983e-d6ec3f16059f -SkuID ($_).ID } Clean all office License's + Key's Code: Function CleanOSPP { $OfficeAppId = '0ff1ce15-a989-479d-af46-f275c6370663' $SL_ID_PRODUCT_SKU = Get-SLIDList -eQueryIdType SL_ID_APPLICATION -pQueryId $OfficeAppId -eReturnIdType SL_ID_PRODUCT_SKU $SL_ID_ALL_LICENSE_FILES = Get-SLIDList -eQueryIdType SL_ID_APPLICATION -pQueryId $OfficeAppId -eReturnIdType SL_ID_ALL_LICENSE_FILES if ($SL_ID_PRODUCT_SKU) { SL-UninstallProductKey -skuList $SL_ID_PRODUCT_SKU } if ($SL_ID_ALL_LICENSE_FILES) { SL-UninstallLicense -LicenseFileIds $SL_ID_ALL_LICENSE_FILES } } `WMI` query for office & Windows product's Code: $OfficeAppId = '0ff1ce15-a989-479d-af46-f275c6370663' $windowsAppID = '55c92734-d682-4d71-983e-d6ec3f16059f' $WMI_QUERY += Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $windowsAppID | % { Get-LicenseInfo -ActConfigId $_ } start-sleep 1 $WMI_QUERY += Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $OfficeAppId | % { Get-LicenseInfo -ActConfigId $_ } $WMI_QUERY | ? EditionId | select ActConfigId,ProductDescription Install License Example Code: # Path to license file $licensePath = 'C:\Program Files\Microsoft Office\root\Licenses16\client-issuance-bridge-office.xrm-ms' if (-not (Test-Path $licensePath)) { Write-Warning "License file not found: $licensePath" return } # 1. Install license from file path (string) Write-Host "`n--- Installing from file path ---" $result1 = SL-InstallLicense -LicenseInput $licensePath Write-Host "Result (file path): $result1`n" # 2. Install license from byte array Write-Host "--- Installing from byte array ---" $bytes = [System.IO.File]::ReadAllBytes($licensePath) $result2 = SL-InstallLicense -LicenseInput $bytes Write-Host "Result (byte array): $result2`n" # 3. Install license from text string Write-Host "--- Installing from text string ---" $licenseText = Get-Content $licensePath -Raw $result3 = SL-InstallLicense -LicenseInput $licenseText Write-Host "Result (text): $result3`n" Install Product Key example Code: SL-InstallProductKey -Keys "3HYJN-9KG99-F8VG9-V3DT8-JFMHV" SL-InstallProductKey -Keys ("BW9HJ-N9HF7-7M9PW-3PBJR-37DCT","NJ8QJ-PYYXJ-F6HVQ-RYPFK-BKQ86","K8BH4-6TN3G-YXVMY-HBMMF-KBXPT","GMN9H-QCX29-F3JWJ-RYPKC-DDD86","TN6YY-MWHCT-T6PK2-886FF-6RBJ6") Un-Install Product Key example {By SKU `guid` + Key} the function use GUID value, that the read deal. >> const SLID *pPKeyId << Code: <# Example. -- > Remove current windows Key SL-UninstallProductKey -ClearKey $true -- > Remove specific windows key's SL-UninstallProductKey -KeyLst ("3HYJN-9KG99-F8VG9-V3DT8-JFMHV", "JFMHV") -skuList @("dabaa1f2-109b-496d-bf49-1536cc862900") -pkeyList @("e953e4ac-7ce5-0401-e56c-70c13b8e5a82") #> Code: WARNING: Valid key found, JFMHV WARNING: Valid SKU found, dabaa1f2-109b-496d-bf49-1536cc862900 WARNING: Valid PKEY found, e953e4ac-7ce5-0401-e56c-70c13b8e5a82 Attempting to uninstall product key with GUID: e953e4ac-7ce5-0401-e56c-70c13b8e5a82 Product key uninstalled successfully: e953e4ac-7ce5-0401-e56c-70c13b8e5a82 Licensing state change event fired successfully. Proof of purchase installed successfully with KeyType: msft:rm/algorithm/pkey/2009. PKeyId: e953e4ac-7ce5-0401-e56c-70c13b8e5a82 Licensing state change event fired successfully. Uninstall a specifc licenses by demend Code: function Uninstall-Licenses { param ( [string]$WindowsAppId = '55c92734-d682-4d71-983e-d6ec3f16059f', [string]$OfficeAppId = '0ff1ce15-a989-479d-af46-f275c6370663' ) $WMI_QUERY = @() # Get Windows license info $WMI_QUERY += Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $WindowsAppId | % { Get-LicenseInfo -ActConfigId $_ } # Get Office license info start-sleep 1 $WMI_QUERY += Get-SLIDList -eQueryIdType SL_ID_APPLICATION -eReturnIdType SL_ID_PRODUCT_SKU -pQueryId $OfficeAppId | % { Get-LicenseInfo -ActConfigId $_ } # Filter the results to ensure only items with EditionId $filteredResults = $WMI_QUERY | Where-Object { $_.EditionId } | Select-Object ActConfigId, EditionId, ProductDescription # Show the GridView where user can select multiple items, with all columns visible $selectedItems = $filteredResults | Out-GridView -PassThru # If any items are selected if ($selectedItems) { # Extract only ActConfigId GUIDs from the selected items $GUID_ARRAY = $selectedItems | Select-Object -ExpandProperty ActConfigId # Output the GUID array for verification (can be removed later) $GUID_ARRAY # Uninstall the products using the GUID array SL-UninstallProductKey $skuList $GUID_ARRAY SL-UninstallLicense -ProductSKUs $GUID_ARRAY } else { Write-Host "No items selected." } }
Let's play with Dism a little bit Change edition using Low level APi, Or custom Logic involved -> cross reading EditionMappings.xml & EditionMatrix.xml And also, Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_PRODUCT_SKU Code: .SYNOPSIS Retrieves Windows edition upgrade paths and facilitates interactive upgrades. [Bool] USeApi Option, Only available for > *Current* edition .EXAMPLE # Target edition for current system: Get-EditionTargetsFromMatrix .EXAMPLE # Target edition for a specific ID (e.g., 'EnterpriseSN'): Get-EditionTargetsFromMatrix -EditionID 'EnterpriseSN' .EXAMPLE # Upgrade from the current version (interactive selection): Get-EditionTargetsFromMatrix -UpgradeFrom $true .EXAMPLE # Upgrade from a specific base version (e.g., 'EnterpriseSN' or 'CoreCountrySpecific'): Get-EditionTargetsFromMatrix -UpgradeFrom $true -EditionID 'EnterpriseSN' Get-EditionTargetsFromMatrix -UpgradeFrom $true -EditionID 'CoreCountrySpecific' .EXAMPLE # Upgrade to any chosen version (interactive product key selection): Get-EditionTargetsFromMatrix -UpgradeTo $true .EXAMPLE # Upgrade to a specific edition (e.g., 'EnterpriseSEval' with product key selection): Get-EditionTargetsFromMatrix -EditionID EnterpriseSEval -UpgradeTo $true .EXAMPLE # List all available editions: Get-EditionTargetsFromMatrix -ReturnEditionList $true Function Code: $Global:DismAPI = Init-DismApi function Get-EditionTargetsFromMatrix { param ( [Parameter(Mandatory = $false)] [ValidateSet( "ultimate","homebasic","homepremium","enterprise","homebasicn","business","serverstandard","serverdatacenter","serversbsstandard","serverenterprise","starter", "serverdatacentercore","serverstandardcore","serverenterprisecore","serverenterpriseia64","businessn","serverweb","serverhpc","serverhomestandard","serverstorageexpress", "serverstoragestandard","serverstorageworkgroup","serverstorageenterprise","serverwinsb","serversbspremium","homepremiumn","enterprisen","ultimaten","serverwebcore", "servermediumbusinessmanagement","servermediumbusinesssecurity","servermediumbusinessmessaging","serverwinfoundation","serverhomepremium","serverwinsbv","serverstandardv", "serverdatacenterv","serverenterprisev","serverdatacentervcore","serverstandardvcore","serverenterprisevcore","serverhypercore","serverstorageexpresscore","serverstoragestandardcore", "serverstorageworkgroupcore","serverstorageenterprisecore","startern","professional","professionaln","serversolution","serverforsbsolutions","serversolutionspremium", "serversolutionspremiumcore","serversolutionem","serverforsbsolutionsem","serverembeddedsolution","serverembeddedsolutioncore","professionalembedded","serveressentialmanagement", "serveressentialadditional","serveressentialmanagementsvc","serveressentialadditionalsvc","serversbspremiumcore","serverhpcv","embedded","startere","homebasice", "homepremiume","professionale","enterprisee","ultimatee","enterpriseeval","prerelease","servermultipointstandard","servermultipointpremium","serverstandardeval", "serverdatacentereval","prereleasearm","prereleasen","enterpriseneval","embeddedautomotive","embeddedindustrya","thinpc","embeddeda","embeddedindustry","embeddede", "embeddedindustrye","embeddedindustryae","professionalplus","serverstorageworkgroupeval","serverstoragestandardeval","corearm","coren","corecountryspecific","coresinglelanguage", "core","professionalwmc","mobilecore","embeddedindustryeval","embeddedindustryeeval","embeddedeval","embeddedeeval","coresystemserver","servercloudstorage","coreconnected", "professionalstudent","coreconnectedn","professionalstudentn","coreconnectedsinglelanguage","coreconnectedcountryspecific","connectedcar","industryhandheld", "ppipro","serverarm64","education","educationn","iotuap","serverhi","enterprises","enterprisesn","professionals","professionalsn","enterpriseseval", "enterprisesneval","iotuapcommercial","mobileenterprise","analogonecore","holographic","professionalsinglelanguage","professionalcountryspecific","enterprisesubscription", "enterprisesubscriptionn","serverdatacenternano","serverstandardnano","serverdatacenteracor","serverstandardacor","serverdatacentercor","serverstandardcor","utilityvm", "serverdatacenterevalcor","serverstandardevalcor","professionalworkstation","professionalworkstationn","serverazure","professionaleducation","professionaleducationn", "serverazurecor","serverazurenano","enterpriseg","enterprisegn","businesssubscription","businesssubscriptionn","serverrdsh","cloud","cloudn","hubos","onecoreupdateos", "cloude","andromeda","iotos","clouden","iotedgeos","iotenterprise","modernpc","iotenterprises","systemos","nativeos","gamecorexbox","gameos","durangohostos", "scarletthostos","keystone","cloudhost","cloudmos","cloudcore","cloudeditionn","cloudedition","winvos","iotenterprisesk","iotenterprisek","iotenterpriseseval", "agentbridge","nanohost","wnc","serverazurestackhcicor","serverturbine","serverturbinecor" )] [string]$EditionID = $null, [Parameter(Mandatory = $false)] [bool]$ReturnEditionList = $false, [Parameter(Mandatory = $false)] [bool]$UpgradeFrom = $false, [Parameter(Mandatory = $false)] [bool]$UpgradeTo = $false, [Parameter(Mandatory = $false)] [bool]$UseApi = $false ) [string]$xmlPath = "C:\Windows\servicing\Editions\EditionMappings.xml" [string]$MatrixPath = "C:\Windows\servicing\Editions\EditionMatrix.xml" if (-not $xmlPath -or -not $MatrixPath) { Write-Host Write-Warning "Required files not found: `n$xmlPath`n$MatrixPath" return } $CurrentEdition = Get-ProductID if ($UseApi -and ( $EditionID -and ($EditionID -ne $CurrentEdition))) { Write-Warning "UseApi Only for Current edition." return @() } function Find-Upgrades { param ( [Parameter(Mandatory = $true)] [ValidateNotNullOrEmpty()] [string]$EditionID ) if ($EditionID -and ($Global:productTypeTable.ProductID -notcontains $EditionID)) { Write-Warning "EditionID '$EditionID' is not found in the product type table." return } $parentEdition = $null $relatedEditions = @() [xml]$xml = Get-Content -Path $xmlPath $WindowsEditions = $xml.WindowsEditions.Edition $isVirtual = $WindowsEditions.Name -contains $EditionID $isParent = $WindowsEditions.ParentEdition -contains $EditionID # If the selected edition is a Virtual Edition, get the Parent Edition if ($isVirtual) { $selectedEditionNode = $WindowsEditions | Where-Object { $_.Name -eq $EditionID } $parentEdition = $selectedEditionNode.ParentEdition } # If the edition is a Parent Edition, find all related Virtual Editions if ($isParent) { try { $relatedEditions = $WindowsEditions | Where-Object { $_.ParentEdition -eq $EditionID -and $_.virtual -eq "true" } } catch { } } # If the edition is a Virtual Edition, find all other Virtual Editions linked to the same Parent Edition if ($isVirtual) { try { $relatedEditions += $WindowsEditions | Where-Object { $_.ParentEdition -eq $parentEdition -and $_.virtual -eq "true" } } catch { } } return [PSCustomObject]@{ Editions = $relatedEditions | Select-Object -ExpandProperty Name Parent = $parentEdition } } Function Dism-GetTargetEditions { try { $hr = $Global:DismAPI::DismInitialize(0, [IntPtr]::Zero, [IntPtr]::Zero) if ($hr -ne 0) { Write-Warning "DismInitialize failed: $hr" return @() } $session = [IntPtr]::Zero $hr = $Global:DismAPI::DismOpenSession("DISM_{53BFAE52-B167-4E2F-A258-0A37B57FF845}", [IntPtr]::Zero, [IntPtr]::Zero, [ref]$session) if ($hr -ne 0) { Write-Warning "DismOpenSession failed: $hr" return } $count = 0 $editionIds = [IntPtr]::Zero $hr = $Global:DismAPI::_DismGetTargetEditions($session, [ref]$editionIds, [ref]$count) if ($hr -ne 0) { Write-Warning "_DismGetTargetEditions failed: $hr" } if ($hr -eq 0 -and $count -gt 0) { try { return Convert-PointerArrayToStrings -PointerToArray $editionIds -Count $count } catch { Write-Warning "Failed to convert editions: $_" return @() } } } catch { } finally { if ($editionIds -and ( $editionIds -ne [IntPtr]::Zero)) { $null = $Global:DismAPI::DismDelete($editionIds) } if ($session -and ( $session -ne [IntPtr]::Zero)) { $null = $Global:DismAPI::DismCloseSession($session) } $null = $Global:DismAPI::DismShutdown() } } function Convert-PointerArrayToStrings { param ( [Parameter(Mandatory = $true)] [IntPtr] $PointerToArray, [Parameter(Mandatory = $true)] [UInt32] $Count ) if ($PointerToArray -eq [IntPtr]::Zero -or $Count -eq 0) { return @() } $strings = @() for ($i = 0; $i -lt $Count; $i++) { # Calculate pointer to pointer at index $i $ptrToStringPtr = [IntPtr]::Add($PointerToArray, $i * [IntPtr]::Size) # Read the string pointer $stringPtr = [Runtime.InteropServices.Marshal]::ReadIntPtr($ptrToStringPtr) if ($stringPtr -ne [IntPtr]::Zero) { # Read the Unicode string from the pointer $edition = [Runtime.InteropServices.Marshal]::PtrToStringUni($stringPtr) $strings += $edition } } return $strings } if (-Not (Test-Path $MatrixPath)) { Write-Error "EditionMatrix.xml not found at $MatrixPath" return } if ($EditionID -and ($Global:productTypeTable.ProductID -notcontains $EditionID)) { Write-Warning "EditionID '$EditionID' is not found in the product type table." return } [xml]$xml = Get-Content $MatrixPath $LicensingProducts = Get-SLIDList -eQueryIdType SL_ID_PRODUCT_SKU -eReturnIdType SL_ID_PRODUCT_SKU | % { [PSCustomObject]@{ ID = $_ Description = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Description' Name = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'productName' LicenseFamily = Get-LicenseDetails -ActConfigId $_ -pwszValueName 'Family' } } $uniqueFamilies = $LicensingProducts.LicenseFamily | Select-Object -Unique if ($UpgradeFrom) { if (-not $EditionID) { $EditionID = $CurrentEdition } if (-not $EditionID) { Write-Host Write-Warning "EditionID is missing. Upgrade may not proceed correctly." return } # Find edition node in XML # Editions where this ID is the source (normal lookup) $sourceNode = $xml.TmiMatrix.Edition | Where-Object { $_.ID -eq $EditionID } # Editions where this ID is a target (reverse lookup) $targetNodes = $xml.TmiMatrix.Edition | Where-Object { $_.Target.ID -contains $EditionID } # Combine all $editionNode = @() if ($sourceNode) { $editionNode += $sourceNode } if ($targetNodes) { $editionNode += $targetNodes } $Upgrades = Find-Upgrades -EditionID $EditionID if ($UseApi -and ( $EditionID -eq $CurrentEdition)) { $targetEditions = Dism-GetTargetEditions } else { $targetEditions = @($editionNode.Target.ID + $Upgrades.Editions + $Upgrades.Parent) | ? { $_ -ne $CurrentEdition} | select -Unique if (-not $targetEditions) { Write-Host Write-Warning "No upgrade targets found for EditionID '$EditionID'." return } $targetEditions = $targetEditions | Where-Object { $uniqueFamilies -contains $_ } | select -Unique } if ($targetEditions.Count -eq 0) { Write-Host Write-Warning "No targets license's found in Current system for '$EditionID' Edition." return } elseif ($targetEditions.Count -eq 1) { $chosenTarget = $targetEditions Write-Host Write-Warning "Only one upgrade target found: $chosenTarget. Selecting automatically." } else { # Multiple targets: let user choose $chosenTarget = $null while (-not $chosenTarget) { Clear-Host Write-Host Write-Host "[Available upgrade targets]" Write-Host for ($i = 0; $i -lt $targetEditions.Count; $i++) { Write-Host "[$($i+1)] $($targetEditions[$i])" } $selection = Read-Host "Select upgrade target edition by number (or 'q' to quit)" if ($selection -eq 'q') { break } $parsedSelection = 0 if ([int]::TryParse($selection, [ref]$parsedSelection) -and $parsedSelection -ge 1 -and $parsedSelection -le $targetEditions.Count) { $chosenTarget = $targetEditions[$parsedSelection - 1] } else { Write-Host "Invalid selection, please try again." Start-Sleep -Seconds 1 } } } if (-not $chosenTarget) { Write-Host Write-Warning "No target edition selected. Cancelling." return } $UpgradeTo = $true $EditionID = $chosenTarget } if ($UpgradeTo) { $filteredKeys = $Global:PKeyDatabase | ? { $LicensingProducts.ID -contains $_.ActConfigId} if ($EditionID) { if ($EditionID -eq $CurrentEdition) { Write-Host Write-Warning "Attempting to upgrade to the same edition ($EditionID) already installed. No upgrade needed." return } $matchingKeys = @($filteredKeys | Where-Object { $_.EditionId -eq $EditionID }) if (-not $matchingKeys -or $matchingKeys.Count -eq 0) { Write-Host Write-Warning "No matching keys found for EditionID '$EditionID'" return } } else { # No EditionID specified, use all keys $matchingKeys = @($filteredKeys) } if (-not $matchingKeys -or $matchingKeys.Count -eq 0) { Write-Host Write-Warning "No product keys available." return } if ($matchingKeys.Count -gt 1) { # Multiple keys: show Out-GridView for selection $selectedKey = $null while (-not $selectedKey) { Clear-Host Write-Host Write-Host "[Available product keys]" Write-Host for ($i = 0; $i -lt $matchingKeys.Count; $i++) { $item = $matchingKeys[$i] Write-Host ("{0,-4} {1,-30} | {2,-50} | {3,-15} | {4}" -f ("[$($i+1)]"), $item.EditionId, $item.ProductDescription, $item.ProductKeyType, $item.RefGroupId) } Write-Host $input = Read-Host "Select a product key by number (or 'q' to quit)" if ($input -eq 'q') { break } $parsed = 0 if ([int]::TryParse($input, [ref]$parsed) -and $parsed -ge 1 -and $parsed -le $matchingKeys.Count) { $selectedKey = $matchingKeys[$parsed - 1] } else { Write-Host "Invalid selection. Please try again." Start-Sleep -Seconds 1 } } if (-not $selectedKey) { Write-Host Write-Warning "No selection made. Operation cancelled." return } } elseif ($matchingKeys.Count -eq 1) { # Only one key: select automatically $selectedKey = $matchingKeys } else { Write-Host Write-Warning "No product keys available." return } if (-not $selectedKey) { Write-Host Write-Warning "No selection made. Operation cancelled." return } # Simulated Key Installation Write-Host SL-InstallProductKey -Keys @( (KeyEncode -sgroupid $($selectedKey.RefGroupId) -skeyid 0 -sunk 0)) return } if (-not $EditionID) { $EditionID = Get-ProductID } if ($ReturnEditionList) { return $xml.TmiMatrix.Edition | Select-Object -ExpandProperty ID } if ($UseApi -and ( $EditionID -eq $CurrentEdition)) { $targets = Dism-GetTargetEditions } else { $Upgrades = Find-Upgrades -EditionID $EditionID $editionNode = $xml.TmiMatrix.Edition | Where-Object { $_.ID -eq $EditionID } $targets = ($editionNode.Target.ID + $Upgrades.Editions + $Upgrades.Parent) | ? {$_ -ne $CurrentEdition} | Sort-Object -Unique } if ($targets) { Write-Host Write-Host "Edition '$EditionID' can be upgraded to:" -ForegroundColor Green $targets | ForEach-Object { " - $_" } } else { Write-Host Write-Warning "Edition '$EditionID' has no defined upgrade targets." } } Init Part Code: <# Managed DismApi Wrapper https://github.com/jeffkl/ManagedDism/tree/main Windows 10 DLL File Information - DismApi.dll https://windows10dll.nirsoft.net/dismapi_dll.html DISMSDK https://github.com/Chuyu-Team/DISMSDK/blob/main/dismapi.h DISM API Functions https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/dism/dism-api-functions #> function Init-DismApi { $Method = [PSCustomObject]@{ attributes = [System.Reflection.MethodAttributes]::Public -bor ` [System.Reflection.MethodAttributes]::Static -bor ` [System.Reflection.MethodAttributes]::PinvokeImpl CallingConventions = [System.Reflection.CallingConventions]::Standard nativeCallConv = [System.Runtime.InteropServices.CallingConvention]::Winapi nativeCharSet = [System.Runtime.InteropServices.CharSet]::Unicode ImplAttributes = [System.Reflection.MethodImplAttributes]::PreserveSig TypeAttributes = [System.Reflection.TypeAttributes]::Public -bor ` [System.Reflection.TypeAttributes]::Abstract -bor ` [System.Reflection.TypeAttributes]::Sealed } $asm = [AppDomain]::CurrentDomain.DefineDynamicAssembly( (New-Object System.Reflection.AssemblyName "DismApi"), [System.Reflection.Emit.AssemblyBuilderAccess]::Run ) $mod = $asm.DefineDynamicModule("DismApiModule") $tb = $mod.DefineType("DismMethods", $Method.TypeAttributes) $functions = @( @{ Name = "DismInitialize"; ReturnType = [Int32]; # logLevel, logFilePath, scratchDirectory Parameters = [Type[]]@([Int32], [IntPtr], [IntPtr]) }, @{ Name = "DismOpenSession"; ReturnType = [Int32]; # imagePath, windowsDirectory, systemDrive, out session Parameters = [Type[]]@([string], [IntPtr], [IntPtr], [IntPtr].MakeByRefType()) }, @{ Name = "DismCloseSession"; ReturnType = [Int32]; # session handle Parameters = [Type[]]@([IntPtr]) }, @{ Name = "_DismGetTargetEditions"; ReturnType = [Int32]; # session, out editionIds, out count Parameters = [Type[]]@([IntPtr], [IntPtr].MakeByRefType(), [UInt32].MakeByRefType()) }, @{ Name = "DismShutdown"; ReturnType = [Int32]; # no parameters Parameters = [Type[]]@() }, @{ Name = "DismDelete"; ReturnType = [Int32]; # parameter is a void* pointer to the structure to free Parameters = [Type[]]@([IntPtr]) } ) foreach ($f in $functions) { # Handle 'ref' params properly by making ByRefType $paramTypes = foreach ($p in $f.Parameters) { if ($p -is [System.Management.Automation.PSReference]) { # For simplicity, already handled $p } elseif ($p.Name -eq "ByRef") { # N/A here, skip $p } else { $p } } $tb.DefinePInvokeMethod( $f.Name, "DismApi.dll", $Method.attributes, $Method.CallingConventions, $f.ReturnType, $f.Parameters, $Method.nativeCallConv, $Method.nativeCharSet ).SetImplementationFlags($Method.ImplAttributes) | Out-Null } return $tb.CreateType() }