diff --git a/MAS/All-In-One-Version-KL/MAS_AIO.cmd b/MAS/All-In-One-Version-KL/MAS_AIO.cmd
index fc5db47..b5a94e7 100644
--- a/MAS/All-In-One-Version-KL/MAS_AIO.cmd
+++ b/MAS/All-In-One-Version-KL/MAS_AIO.cmd
@@ -12508,6 +12508,7 @@ $IID = $IID.IsPresent -Or $Dlv.IsPresent
 
 $NT6 = $winbuild -GE 6000
 $NT7 = $winbuild -GE 7600
+$NT8 = $winbuild -GE 9200
 $NT9 = $winbuild -GE 9600
 
 $Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
@@ -12583,55 +12584,375 @@ function CheckOhook
 	& $noAll
 }
 
-#region WMI
-function DetectID($strSLP, $strAppId)
-{
-	$ppk = (" AND PartialProductKey <> NULL)", ")")[$All.IsPresent]
-	$fltr = "SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId'"
-	$clause = $fltr + $ppk
-	$sWmi = [wmisearcher]$clause
-	$sWmi.Options.Rewindable = $false
-	return ($sWmi.Get().Count -GT 0)
+#region SSSS
+function BoolToWStr($bVal) {
+	("TRUE", "FALSE")[!$bVal]
 }
 
-function GetID($strSLP, $strAppId)
-{
-	$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
-	$IDs = [Collections.ArrayList]@()
-	$isAdd = (" AND LicenseDependsOn <> NULL)", ")")[$NT5]
-	$noAdd = " AND LicenseDependsOn IS NULL)"
-	$query = "SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId' AND PartialProductKey"
+function InitializePInvoke($LaDll, $bOffice) {
+	$Marshal = [System.Runtime.InteropServices.Marshal]
+	$Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly((Get-Random), 'Run').DefineDynamicModule((Get-Random), $False)
+	$SLApp = $NT7 -Or $bOffice -Or ($LaDll -EQ 'sppc.dll' -And [Diagnostics.FileVersionInfo]::GetVersionInfo("$SysPath\sppc.dll").FilePrivatePart -GE 16501)
 
-	if ($All.IsPresent) {
-		$fltr = $query + " IS NULL"
-		$clause = $fltr + $isAdd
-		$sWmi = [wmisearcher]$clause
-		$sWmi.Options.Rewindable = $false
-		try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
-		if (-Not $NT5) {
-		$clause = $fltr + $noAdd
-		$sWmi = [wmisearcher]$clause
-		$sWmi.Options.Rewindable = $false
-		try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
+	$Win32 = $null
+	$Class = $Module.DefineType((Get-Random), 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0)
+	$Class.DefinePInvokeMethod('SLClose', $LaDll, 22, 1, [Int32], @([IntPtr]), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLOpen', $LaDll, 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGenerateOfflineInstallationId', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetSLIDList', $LaDll, 22, 1, [Int32], @([IntPtr], [UInt32], [Guid].MakeByRefType(), [UInt32], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetLicensingStatusInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [Guid].MakeByRefType(), [IntPtr], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetPKeyInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetProductSkuInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetServiceInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	if ($SLApp) {
+		$Class.DefinePInvokeMethod('SLGetApplicationInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	}
+	if ($bOffice) {
+		$Win32 = $Class.CreateType()
+		return
+	}
+	if ($NT6) {
+		$Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+		$Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+		$Class.DefinePInvokeMethod('SLIsGenuineLocal', 'slwga.dll', 22, 1, [Int32], @([Guid].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr]), 1, 3).SetImplementationFlags(128)
+	}
+	if ($NT7) {
+		$Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig')
+	}
+
+	if ($DllSubscription) {
+		$Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+		$Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0)
+		[void]$Struct.DefineField('dwEnabled', [UInt32], 'Public')
+		[void]$Struct.DefineField('dwSku', [UInt32], 6)
+		[void]$Struct.DefineField('dwState', [UInt32], 6)
+		$SubStatus = $Struct.CreateType()
+	}
+
+	$Win32 = $Class.CreateType()
+}
+
+function SlGetInfoIID($SkuId)
+{
+	$bData = 0
+
+	if ($Win32::SLGenerateOfflineInstallationId(
+		$hSLC,
+		[ref][Guid]$SkuId,
+		[ref]$bData
+	))
+	{
+		return $null
+	}
+
+	$rData = $Marshal::PtrToStringUni($bData)
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoSku($SkuId, $Value)
+{
+	$tData = 0
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetProductSkuInformation(
+		$hSLC,
+		[ref][Guid]$SkuId,
+		$Value,
+		[ref]$tData,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $null
+	}
+
+	if ($tData -EQ 1)
+	{
+		$rData = $Marshal::PtrToStringUni($bData)
+	}
+	elseif ($tData -EQ 4)
+	{
+		$rData = $Marshal::ReadInt32($bData)
+	}
+	elseif ($tData -EQ 3 -And $cData -EQ 8)
+	{
+		$rData = $Marshal::ReadInt64($bData)
+	}
+	else
+	{
+		$rData = $null
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoService($Value)
+{
+	$tData = 0
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetServiceInformation(
+		$hSLC,
+		$Value,
+		[ref]$tData,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $null
+	}
+
+	if ($tData -EQ 1)
+	{
+		$rData = $Marshal::PtrToStringUni($bData)
+	}
+	elseif ($tData -EQ 4)
+	{
+		$rData = $Marshal::ReadInt32($bData)
+	}
+	elseif ($tData -EQ 3 -And $cData -EQ 8)
+	{
+		$rData = $Marshal::ReadInt64($bData)
+	}
+	else
+	{
+		$rData = $null
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoApp($AppId, $Value)
+{
+	$tData = 0
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetApplicationInformation(
+		$hSLC,
+		[ref][Guid]$AppId,
+		$Value,
+		[ref]$tData,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $null
+	}
+
+	if ($tData -EQ 1)
+	{
+		$rData = $Marshal::PtrToStringUni($bData)
+	}
+	elseif ($tData -EQ 4)
+	{
+		$rData = $Marshal::ReadInt32($bData)
+	}
+	elseif ($tData -EQ 3 -And $cData -EQ 8)
+	{
+		$rData = $Marshal::ReadInt64($bData)
+	}
+	else
+	{
+		$rData = $null
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoSvcApp($strApp, $Value)
+{
+	if ($SLApp)
+	{
+		$rData = SlGetInfoApp $strApp $Value
+	}
+	else
+	{
+		$rData = SlGetInfoService $Value
+	}
+	return $rData
+}
+
+function SlGetInfoPKey($PkeyId, $Value)
+{
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetPKeyInformation(
+		$hSLC,
+		[ref][Guid]$PKeyId,
+		$Value,
+		[ref]$null,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $null
+	}
+
+	$rData = $Marshal::PtrToStringUni($bData)
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoLicensing($AppId, $SkuId)
+{
+	$LicenseStatus = 0
+	$GracePeriodRemaining = 0
+	$hrReason = 0
+	$EvaluationEndDate = 0
+
+	$cStatus = 0
+	$pStatus = 0
+
+	$ret = $Win32::SLGetLicensingStatusInformation(
+		$hSLC,
+		[ref][Guid]$AppId,
+		[ref][Guid]$SkuId,
+		0,
+		[ref]$cStatus,
+		[ref]$pStatus
+	)
+
+	if ($ret -Or !$cStatus)
+	{
+		return
+	}
+
+	[IntPtr]$ppStatus = [Int64]$pStatus + [Int64]40 * ($cStatus - 1)
+	$eStatus = $Marshal::ReadInt32($ppStatus, 16)
+	$GracePeriodRemaining = $Marshal::ReadInt32($ppStatus, 20)
+	$hrReason = $Marshal::ReadInt32($ppStatus, 28)
+	$EvaluationEndDate = $Marshal::ReadInt64($ppStatus, 32)
+
+	if ($eStatus -EQ 3)
+	{
+		$eStatus = 5
+	}
+	if ($eStatus -EQ 2)
+	{
+		if ($hrReason -EQ 0x4004F00D)
+		{
+			$eStatus = 3
+		}
+		elseif ($hrReason -EQ 0x4004F065)
+		{
+			$eStatus = 4
+		}
+		elseif ($hrReason -EQ 0x4004FC06)
+		{
+			$eStatus = 6
 		}
 	}
+	$LicenseStatus = $eStatus
 
-	$fltr = $query + " <> NULL"
-	$clause = $fltr + $isAdd
-	$sWmi = [wmisearcher]$clause
-	$sWmi.Options.Rewindable = $false
-	try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
-	if (-Not $NT5) {
-	$clause = $fltr + $noAdd
-	$sWmi = [wmisearcher]$clause
-	$sWmi.Options.Rewindable = $false
-	try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
+	$Marshal::FreeHGlobal($pStatus)
+	return
+}
+
+function SlCheckInfo($SkuId, $Value)
+{
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetProductSkuInformation(
+		$hSLC,
+		[ref][Guid]$SkuId,
+		$Value,
+		[ref]$null,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $false
 	}
 
-	return $IDs
+	if ($Value -EQ "pkeyId")
+	{
+		$rData = $Marshal::PtrToStringUni($bData)
+	}
+	else
+	{
+		$rData = $true
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoSLID($AppId)
+{
+	$cReturnIds = 0
+	$pReturnIds = 0
+
+	$ret = $Win32::SLGetSLIDList(
+		$hSLC,
+		0,
+		[ref][Guid]$AppId,
+		1,
+		[ref]$cReturnIds,
+		[ref]$pReturnIds
+	)
+
+	if ($ret -Or !$cReturnIds)
+	{
+		return
+	}
+
+	$a1List = @()
+	$a2List = @()
+	$a3List = @()
+	$a4List = @()
+
+	foreach ($i in 0..($cReturnIds - 1))
+	{
+		$bytes = New-Object byte[] 16
+		$Marshal::Copy([Int64]$pReturnIds + [Int64]16 * $i, $bytes, 0, 16)
+		$actid = ([Guid]$bytes).Guid
+		$gPPK = SlCheckInfo $actid "pkeyId"
+		$gAdd = SlCheckInfo $actid "DependsOn"
+		if ($All.IsPresent) {
+			if (!$gPPK -And $gAdd) { $a1List += @{id = $actid; pk = $null; ex = $true} }
+			if (!$gPPK -And !$gAdd) { $a2List += @{id = $actid; pk = $null; ex = $false} }
+		}
+		if ($gPPK -And $gAdd) { $a3List += @{id = $actid; pk = $gPPK; ex = $true} }
+		if ($gPPK -And !$gAdd) { $a4List += @{id = $actid; pk = $gPPK; ex = $false} }
+	}
+
+	$Marshal::FreeHGlobal($pReturnIds)
+	return ($a1List + $a2List + $a3List + $a4List)
 }
 
 function DetectSubscription {
+	try
+	{
+		$objSvc = New-Object PSObject
+		$wmiSvc = [wmisearcher]"SELECT SubscriptionType, SubscriptionStatus, SubscriptionEdition, SubscriptionExpiry FROM SoftwareLicensingService"
+		$wmiSvc.Options.Rewindable = $false
+		$wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { $objSvc | Add-Member 8 $_.Name $_.Value }
+		$wmiSvc.Dispose()
+	}
+	catch
+	{
+		return
+	}
+
 	if ($null -EQ $objSvc.SubscriptionType -Or $objSvc.SubscriptionType -EQ 120) {
 		return
 	}
@@ -12663,161 +12984,188 @@ function DetectSubscription {
 	}
 
 	CONOUT "`nSubscription information:"
-	CONOUT "    Edition: $SubMsgEdition"
 	CONOUT "    Type   : $SubMsgType"
 	CONOUT "    Status : $SubMsgStatus"
+	CONOUT "    Edition: $SubMsgEdition"
 	CONOUT "    Expiry : $SubMsgExpiry"
 }
 
 function DetectAdbaClient
 {
+	$propADBA | foreach { set $_ (SlGetInfoSku $ID $_) }
 	CONOUT "`nAD Activation client information:"
 	CONOUT "    Object Name: $ADActivationObjectName"
 	CONOUT "    Domain Name: $ADActivationObjectDN"
-	CONOUT "    CSVLK Extended PID: $ADActivationCsvlkPid"
-	CONOUT "    CSVLK Activation ID: $ADActivationCsvlkSkuId"
+	CONOUT "    CSVLK Extended PID: $ADActivationCsvlkPID"
+	CONOUT "    CSVLK Activation ID: $ADActivationCsvlkSkuID"
 }
 
 function DetectAvmClient
 {
+	$propAVMA | foreach { set $_ (SlGetInfoSku $ID $_) }
 	CONOUT "`nAutomatic VM Activation client information:"
-	if (-Not [String]::IsNullOrEmpty($IAID)) {
-		CONOUT "    Guest IAID: $IAID"
+	if (-Not [String]::IsNullOrEmpty($InheritedActivationId)) {
+		CONOUT "    Guest IAID: $InheritedActivationId"
 	} else {
 		CONOUT "    Guest IAID: Not Available"
 	}
-	if (-Not [String]::IsNullOrEmpty($AutomaticVMActivationHostMachineName)) {
-		CONOUT "    Host machine name: $AutomaticVMActivationHostMachineName"
+	if (-Not [String]::IsNullOrEmpty($InheritedActivationHostMachineName)) {
+		CONOUT "    Host machine name: $InheritedActivationHostMachineName"
 	} else {
 		CONOUT "    Host machine name: Not Available"
 	}
-	if ($AutomaticVMActivationLastActivationTime.Substring(0,4) -NE "1601") {
-		$EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($AutomaticVMActivationLastActivationTime),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt')
-		CONOUT "    Activation time: $EED UTC"
-	} else {
-		CONOUT "    Activation time: Not Available"
-	}
-	if (-Not [String]::IsNullOrEmpty($AutomaticVMActivationHostDigitalPid2)) {
-		CONOUT "    Host Digital PID2: $AutomaticVMActivationHostDigitalPid2"
+	if (-Not [String]::IsNullOrEmpty($InheritedActivationHostDigitalPid2)) {
+		CONOUT "    Host Digital PID2: $InheritedActivationHostDigitalPid2"
 	} else {
 		CONOUT "    Host Digital PID2: Not Available"
 	}
+	if ($InheritedActivationActivationTime) {
+		$IAAT = [DateTime]::FromFileTime($InheritedActivationActivationTime).ToString('yyyy-MM-dd hh:mm:ss tt')
+		CONOUT "    Activation time: $IAAT"
+	} else {
+		CONOUT "    Activation time: Not Available"
+	}
 }
 
 function DetectKmsHost
 {
+	$IsKeyManagementService = SlGetInfoSvcApp $strApp 'IsKeyManagementService'
+	if (-Not $IsKeyManagementService) {
+		return
+	}
+	if ($null -NE $ExpireMsg) {CONOUT "`n    $ExpireMsg"}
+
 	if ($Vista -Or $NT5) {
-		$KeyManagementServiceListeningPort = strGetRegistry $SLKeyPath "KeyManagementServiceListeningPort"
-		$KeyManagementServiceDnsPublishing = strGetRegistry $SLKeyPath "DisableDnsPublishing"
-		$KeyManagementServiceLowPriority = strGetRegistry $SLKeyPath "EnableKmsLowPriority"
-		if (-Not $KeyManagementServiceDnsPublishing) {$KeyManagementServiceDnsPublishing = "TRUE"}
-		if (-Not $KeyManagementServiceLowPriority) {$KeyManagementServiceLowPriority = "FALSE"}
+		$regk = $SLKeyPath
+	} elseif ($strSLP -EQ $oslp) {
+		$regk = $OPKeyPath
 	} else {
-		$KeyManagementServiceListeningPort = $objSvc.KeyManagementServiceListeningPort
-		$KeyManagementServiceDnsPublishing = $objSvc.KeyManagementServiceDnsPublishing
-		$KeyManagementServiceLowPriority = $objSvc.KeyManagementServiceLowPriority
+		$regk = $SPKeyPath
+	}
+	$KMSListening = strGetRegistry $regk "KeyManagementServiceListeningPort"
+	$KMSPublishing = strGetRegistry $regk "DisableDnsPublishing"
+	$KMSPriority = strGetRegistry $regk "EnableKmsLowPriority"
+
+	if (-Not $KMSListening) {$KMSListening = 1688}
+	if (-Not $KMSPublishing) {$KMSPublishing = "TRUE"} else {$KMSPublishing = BoolToWStr (!$KMSPublishing)}
+	if (-Not $KMSPriority) {$KMSPriority = "FALSE"} else {$KMSPriority = BoolToWStr $KMSPriority}
+
+	if ($KMSPublishing -EQ "TRUE") {$KMSPublishing = "Enabled"} else {$KMSPublishing = "Disabled"}
+	if ($KMSPriority -EQ "TRUE") {$KMSPriority = "Low"} else {$KMSPriority = "Normal"}
+
+	if ($SLApp)
+	{
+		$propKMSServer | foreach { set $_ (SlGetInfoApp $strApp $_) }
+	}
+	else
+	{
+		$propKMSServer | foreach { set $_ (SlGetInfoService $_) }
 	}
 
-	if (-Not $KeyManagementServiceListeningPort) {$KeyManagementServiceListeningPort = 1688}
-	if ($KeyManagementServiceDnsPublishing -EQ "TRUE") {
-		$KeyManagementServiceDnsPublishing = "Enabled"
-	} else {
-		$KeyManagementServiceDnsPublishing = "Disabled"
-	}
-	if ($KeyManagementServiceLowPriority -EQ "TRUE") {
-		$KeyManagementServiceLowPriority = "Low"
-	} else {
-		$KeyManagementServiceLowPriority = "Normal"
-	}
+	$KMSRequests = $KeyManagementServiceTotalRequests
+	$NoRequests = ($null -EQ $KMSRequests) -Or ($KMSRequests -EQ -1) -Or ($KMSRequests -EQ 4294967295)
 
 	CONOUT "`nKey Management Service host information:"
 	CONOUT "    Current count: $KeyManagementServiceCurrentCount"
-	CONOUT "    Listening on Port: $KeyManagementServiceListeningPort"
-	CONOUT "    DNS publishing: $KeyManagementServiceDnsPublishing"
-	CONOUT "    KMS priority: $KeyManagementServiceLowPriority"
-	if (-Not [String]::IsNullOrEmpty($KeyManagementServiceTotalRequests)) {
-		CONOUT "`nKey Management Service cumulative requests received from clients:"
-		CONOUT "    Total: $KeyManagementServiceTotalRequests"
-		CONOUT "    Failed: $KeyManagementServiceFailedRequests"
-		CONOUT "    Unlicensed: $KeyManagementServiceUnlicensedRequests"
-		CONOUT "    Licensed: $KeyManagementServiceLicensedRequests"
-		CONOUT "    Initial grace period: $KeyManagementServiceOOBGraceRequests"
-		CONOUT "    Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests"
-		CONOUT "    Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests"
-		if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT "    Notification: $KeyManagementServiceNotificationRequests"}
+	CONOUT "    Listening on Port: $KMSListening"
+	CONOUT "    DNS publishing: $KMSPublishing"
+	CONOUT "    KMS priority: $KMSPriority"
+	if ($NoRequests) {
+		return
 	}
+	CONOUT "`nKey Management Service cumulative requests received from clients:"
+	CONOUT "    Total: $KeyManagementServiceTotalRequests"
+	CONOUT "    Failed: $KeyManagementServiceFailedRequests"
+	CONOUT "    Unlicensed: $KeyManagementServiceUnlicensedRequests"
+	CONOUT "    Licensed: $KeyManagementServiceLicensedRequests"
+	CONOUT "    Initial grace period: $KeyManagementServiceOOBGraceRequests"
+	CONOUT "    Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests"
+	CONOUT "    Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests"
+	if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT "    Notification: $KeyManagementServiceNotificationRequests"}
 }
 
 function DetectKmsClient
 {
-	if ($null -NE $VLActivationTypeEnabled) {CONOUT "Configured Activation Type: $($VLActTypes[$VLActivationTypeEnabled])"}
+	if ($strSLP -EQ $wslp -And $NT8)
+	{
+		$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp + '\' + $ID) "VLActivationType"
+		if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp) "VLActivationType"}
+		if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath) "VLActivationType"}
+		if ($null -EQ $VLType -Or $VLType -GT 3) {$VLType = 0}
+	}
+	if ($null -NE $VLType) {CONOUT "Configured Activation Type: $($VLActTypes[$VLType])"}
+
 	CONOUT "`r"
 	if ($LicenseStatus -NE 1) {
 		CONOUT "Please activate the product in order to update KMS client information values."
 		return
 	}
 
-	if ($Vista) {
-		$KeyManagementServicePort = strGetRegistry $SLKeyPath "KeyManagementServicePort"
-		$DiscoveredKeyManagementServiceMachineName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName"
-		$DiscoveredKeyManagementServiceMachinePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort"
+	if ($NT7 -Or $strSLP -EQ $oslp) {
+		$propKMSClient | foreach { set $_ (SlGetInfoSku $ID $_) }
+		if ($strSLP -EQ $oslp) {$regk = $OPKeyPath} else {$regk = $SPKeyPath}
+		$KMSCaching = strGetRegistry $regk "DisableKeyManagementServiceHostCaching"
+		if (-Not $KMSCaching) {$KMSCaching = "TRUE"} else {$KMSCaching = BoolToWStr (!$KMSCaching)}
 	}
 
-	if ([String]::IsNullOrEmpty($KeyManagementServiceMachine)) {
+	"ClientMachineID" | foreach { set $_ (SlGetInfoService $_) }
+
+	if ($Vista) {
+		$propKMSVista | foreach { set $_ (SlGetInfoService $_) }
+		$KeyManagementServicePort = strGetRegistry $SLKeyPath "KeyManagementServicePort"
+		$DiscoveredKeyManagementServiceName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName"
+		$DiscoveredKeyManagementServicePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort"
+	}
+
+	if ([String]::IsNullOrEmpty($KeyManagementServiceName)) {
 		$KmsReg = $null
 	} else {
 		if (-Not $KeyManagementServicePort) {$KeyManagementServicePort = 1688}
-		$KmsReg = "Registered KMS machine name: ${KeyManagementServiceMachine}:${KeyManagementServicePort}"
+		$KmsReg = "Registered KMS machine name: ${KeyManagementServiceName}:${KeyManagementServicePort}"
 	}
 
-	if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceMachineName)) {
+	if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceName)) {
 		$KmsDns = "DNS auto-discovery: KMS name not available"
 		if ($Vista -And -Not $Admin) {$KmsDns = "DNS auto-discovery: Run the script as administrator to retrieve info"}
 	} else {
-		if (-Not $DiscoveredKeyManagementServiceMachinePort) {$DiscoveredKeyManagementServiceMachinePort = 1688}
-		$KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceMachineName}:${DiscoveredKeyManagementServiceMachinePort}"
+		if (-Not $DiscoveredKeyManagementServicePort) {$DiscoveredKeyManagementServicePort = 1688}
+		$KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceName}:${DiscoveredKeyManagementServicePort}"
 	}
 
-	if ($null -NE $objSvc.KeyManagementServiceHostCaching) {
-		if ($objSvc.KeyManagementServiceHostCaching -EQ "TRUE") {
-			$KeyManagementServiceHostCaching = "Enabled"
-		} else {
-			$KeyManagementServiceHostCaching = "Disabled"
+	if ($null -NE $KMSCaching) {
+		if ($KMSCaching -EQ "TRUE") {$KMSCaching = "Enabled"} else {$KMSCaching = "Disabled"}
+	}
+
+	if ($strSLP -EQ $wslp -And $NT9) {
+		if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceIpAddress)) {
+			$DiscoveredKeyManagementServiceIpAddress = "not available"
 		}
 	}
 
 	CONOUT "Key Management Service client information:"
-	CONOUT "    Client Machine ID (CMID): $($objSvc.ClientMachineID)"
+	CONOUT "    Client Machine ID (CMID): $ClientMachineID"
 	if ($null -EQ $KmsReg) {
 		CONOUT "    $KmsDns"
 		CONOUT "    Registered KMS machine name: KMS name not available"
 	} else {
 		CONOUT "    $KmsReg"
 	}
-	if ($null -NE $DiscoveredKeyManagementServiceMachineIpAddress) {CONOUT "    KMS machine IP address: $DiscoveredKeyManagementServiceMachineIpAddress"}
-	CONOUT "    KMS machine extended PID: $KeyManagementServiceProductKeyID"
+	if ($null -NE $DiscoveredKeyManagementServiceIpAddress) {CONOUT "    KMS machine IP address: $DiscoveredKeyManagementServiceIpAddress"}
+	CONOUT "    KMS machine extended PID: $CustomerPID"
 	CONOUT "    Activation interval: $VLActivationInterval minutes"
 	CONOUT "    Renewal interval: $VLRenewalInterval minutes"
-	if ($null -NE $KeyManagementServiceHostCaching) {CONOUT "    KMS host caching: $KeyManagementServiceHostCaching"}
+	if ($null -NE $KMSCaching) {CONOUT "    KMS host caching: $KMSCaching"}
 	if (-Not [String]::IsNullOrEmpty($KeyManagementServiceLookupDomain)) {CONOUT "    KMS SRV record lookup domain: $KeyManagementServiceLookupDomain"}
 }
 
-function GetResult($strSLP, $strSLS, $strID)
+function GetResult($strSLP, $strApp, $entry)
 {
-	try
-	{
-		$objPrd = [wmisearcher]"SELECT * FROM $strSLP WHERE ID='$strID'"
-		$objPrd.Options.Rewindable = $false
-		$objPrd.Get() | select -Expand Properties -EA 0 | foreach { if (-Not [String]::IsNullOrEmpty($_.Value)) {set $_.Name $_.Value} }
-		$objPrd.Dispose()
-	}
-	catch
-	{
-		return
-	}
+	$ID = $entry.id
+	$propPrd | foreach { set $_ (SlGetInfoSku $ID $_) }
+	. SlGetInfoLicensing $strApp $ID
 
-	$winID = ($ApplicationID -EQ $winApp)
-	$winPR = ($winID -And -Not $LicenseIsAddon)
+	$winID = ($strApp -EQ $winApp)
+	$winPR = ($winID -And -Not $entry.ex)
 	$Vista = ($winID -And $NT6 -And -Not $NT7)
 	$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
 	$reapp = ("Windows", "App")[!$winID]
@@ -12827,16 +13175,15 @@ function GetResult($strSLP, $strSLS, $strID)
 	if ($Description | Select-String "TIMEBASED_") {$cTblClient = 1; $_mTag = "Timebased"}
 	if ($Description | Select-String "VIRTUAL_MACHINE_ACTIVATION") {$cAvmClient = 1; $_mTag = "Automatic VM"}
 	if ($null -EQ $cKmsClient) {
-		if ($Description | Select-String "VOLUME_KMS") {$cKmsHost = 1}
+		if ($Description | Select-String "VOLUME_KMS") {$cKmsServer = 1}
 	}
 
 	$_gpr = [Math]::Round($GracePeriodRemaining/1440)
 	if ($_gpr -GT 0) {
-		$_xpr = [DateTime]::Now.addMinutes($GracePeriodRemaining).ToString('yyyy-MM-dd hh:mm:ss tt')
+		$_xpr = [DateTime]::Now.AddMinutes($GracePeriodRemaining).ToString('yyyy-MM-dd hh:mm:ss tt')
 	}
 
-	if ($null -EQ $LicenseStatusReason) {$LicenseStatusReason = -1}
-	$LicenseReason = '0x{0:X}' -f $LicenseStatusReason
+	$LicenseReason = '0x{0:X}' -f $hrReason
 	$LicenseMsg = "Time remaining: $GracePeriodRemaining minute(s) ($_gpr day(s))"
 	if ($LicenseStatus -EQ 0) {
 		$LicenseInf = "Unlicensed"
@@ -12844,8 +13191,8 @@ function GetResult($strSLP, $strSLS, $strID)
 	}
 	if ($LicenseStatus -EQ 1) {
 		$LicenseInf = "Licensed"
-		$LicenseMsg = $null
 		if ($GracePeriodRemaining -EQ 0) {
+			$LicenseMsg = $null
 			$ExpireMsg = "The $prmnt is permanently activated."
 		} else {
 			$LicenseMsg = "$_mTag activation expiration: $GracePeriodRemaining minute(s) ($_gpr day(s))"
@@ -12880,24 +13227,54 @@ function GetResult($strSLP, $strSLS, $strID)
 		if ($null -NE $_xpr) {$ExpireMsg = "Extended grace period ends $_xpr"}
 	}
 
-	if ($winPR -And $PartialProductKey -And -Not $NT9) {
-		$dp4 = strGetRegistry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" "DigitalProductId4"
-		if ($null -NE $dp4) {
-			$ProductKeyChannel = ([System.Text.Encoding]::Unicode.GetString($dp4, 1016, 128)).Trim([char]$null)
+	$pkid = $entry.pk
+	if ($null -NE $pkid) {
+		$propPkey | foreach { set $_ (SlGetInfoPKey $pkid $_) }
+	}
+
+	if ($winPR -And $null -NE $PartialProductKey -And -Not $NT8) {
+		$uxd = SlGetInfoSku $ID 'UXDifferentiator'
+		$script:primary += @{
+			aid = $ID;
+			ppk = $PartialProductKey;
+			chn = $Channel;
+			lst = $LicenseStatus;
+			lcr = $hrReason;
+			ged = $GracePeriodRemaining;
+			evl = $EvaluationEndDate;
+			dff = $uxd
 		}
 	}
 
-	if ($winPR -And $Dlv -And $NT7 -And $null -EQ $RemainingAppReArmCount) {
-		try
+	if ($IID -And $null -NE $PartialProductKey) {
+		$OfflineInstallationId = SlGetInfoIID $ID
+	}
+
+	if ($Dlv) {
+		if ($strSLP -EQ $wslp -And $NT8)
 		{
-			$tmp = [wmisearcher]"SELECT RemainingWindowsReArmCount FROM $strSLS"
-			$tmp.Options.Rewindable = $false
-			$tmp.Get() | select -Expand Properties -EA 0 | foreach {set $_.Name $_.Value}
-			$tmp.Dispose()
+			$RemainingSkuReArmCount = SlGetInfoSku $ID 'RemainingRearmCount'
+			$RemainingAppReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount'
 		}
-		catch
+		else
 		{
+			if (($winID -And $NT7) -Or $strSLP -EQ $oslp)
+			{
+				$RemainingSLReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount'
+			}
+			else
+			{
+				$RemainingSLReArmCount = SlGetInfoService 'RearmCount'
+			}
 		}
+		if ($null -EQ $TrustedTime)
+		{
+			$TrustedTime = SlGetInfoSvcApp $strApp 'TrustedTime'
+		}
+	}
+
+	if ($Dlv -Or $All.IsPresent) {
+		$gPHN = SlCheckInfo $ID "msft:sl/EUL/PHONE/PUBLIC"
 	}
 
 	$add_on = $Name.IndexOf("add-on for", 5)
@@ -12906,73 +13283,56 @@ function GetResult($strSLP, $strSLS, $strID)
 	if ($add_on -EQ -1) {CONOUT "Name: $Name"} else {CONOUT "Name: $($Name.Substring(0, $add_on + 7))"}
 	CONOUT "Description: $Description"
 	CONOUT "Activation ID: $ID"
-	if ($null -NE $ProductKeyID) {CONOUT "Extended PID: $ProductKeyID"}
-	if ($null -NE $ProductKeyID2 -And $Dlv) {CONOUT "Product ID: $ProductKeyID2"}
+	if ($null -NE $DigitalPID) {CONOUT "Extended PID: $DigitalPID"}
+	if ($null -NE $DigitalPID2 -And $Dlv) {CONOUT "Product ID: $DigitalPID2"}
 	if ($null -NE $OfflineInstallationId -And $IID) {CONOUT "Installation ID: $OfflineInstallationId"}
-	if ($null -NE $ProductKeyChannel) {CONOUT "Product Key Channel: $ProductKeyChannel"}
+	if ($null -NE $Channel) {CONOUT "Product Key Channel: $Channel"}
 	if ($null -NE $PartialProductKey) {CONOUT "Partial Product Key: $PartialProductKey"}
 	CONOUT "License Status: $LicenseInf"
 	if ($null -NE $LicenseMsg) {CONOUT "$LicenseMsg"}
-	if ($LicenseStatus -NE 0 -And $EvaluationEndDate.Substring(0,4) -NE "1601") {
-		$EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($EvaluationEndDate),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt')
+	if ($LicenseStatus -NE 0 -And $EvaluationEndDate) {
+		$EED = [DateTime]::FromFileTimeUtc($EvaluationEndDate).ToString('yyyy-MM-dd hh:mm:ss tt')
 		CONOUT "Evaluation End Date: $EED UTC"
 	}
+	if ($LicenseStatus -NE 1 -And $null -NE $gPHN) {
+		$gPHN = $gPHN.ToString()
+		CONOUT "Phone activatable: $gPHN"
+	}
 	if ($Dlv) {
-		if ($null -NE $RemainingWindowsReArmCount) {
-			CONOUT "Remaining Windows rearm count: $RemainingWindowsReArmCount"
+		if ($null -NE $RemainingSLReArmCount) {
+			CONOUT "Remaining $reapp rearm count: $RemainingSLReArmCount"
 		}
-		if ($null -NE $RemainingSkuReArmCount -And $RemainingSkuReArmCount -NE 4294967295) {
+		if ($null -NE $RemainingSkuReArmCount) {
 			CONOUT "Remaining $reapp rearm count: $RemainingAppReArmCount"
 			CONOUT "Remaining SKU rearm count: $RemainingSkuReArmCount"
 		}
-		if ($null -NE $TrustedTime -And $LicenseStatus -NE 0) {
-			$TTD = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($TrustedTime),$null,32).ToString('yyyy-MM-dd hh:mm:ss tt')
+		if ($LicenseStatus -NE 0 -And $TrustedTime) {
+			$TTD = [DateTime]::FromFileTime($TrustedTime).ToString('yyyy-MM-dd hh:mm:ss tt')
 			CONOUT "Trusted time: $TTD"
 		}
 	}
-	if ($LicenseStatus -EQ 0) {
+	if ($null -EQ $PartialProductKey) {
 		return
 	}
 
-	if ($strSLP -EQ $wslp -And $null -NE $PartialProductKey -And $null -NE $ADActivationObjectName -And $VLActivationType -EQ 1) {
+	if ($strSLP -EQ $wslp -And $NT8 -And $VLActivationType -EQ 1) {
 		DetectAdbaClient
 	}
 
-	if ($winID -And $null -NE $cAvmClient -And $null -NE $PartialProductKey) {
+	if ($winID -And $null -NE $cAvmClient) {
 		DetectAvmClient
 	}
 
 	$chkSub = ($winPR -And $cSub)
 
-	$chkSLS = ($null -NE $PartialProductKey) -And ($null -NE $cKmsClient -Or $null -NE $cKmsHost -Or $chkSub)
+	$chkSLS = ($null -NE $cKmsClient -Or $null -NE $cKmsServer -Or $chkSub)
 
 	if (!$chkSLS) {
 		if ($null -NE $ExpireMsg) {CONOUT "`n    $ExpireMsg"}
 		return
 	}
 
-	try
-	{
-		$objSvc = New-Object PSObject
-		$wmiSvc = [wmisearcher]"SELECT * FROM $strSLS"
-		$wmiSvc.Options.Rewindable = $false
-		$wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { if (-Not [String]::IsNullOrEmpty($_.Value)) {$objSvc | Add-Member 8 $_.Name $_.Value} }
-		$wmiSvc.Dispose()
-		if ($null -EQ $IsKeyManagementServiceMachine) {$objSvc.PSObject.Properties | foreach {set $_.Name $_.Value}}
-	}
-	catch
-	{
-		return
-	}
-
-	if ($strSLS -EQ $wsls -And $NT9) {
-		if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceMachineIpAddress)) {
-			$DiscoveredKeyManagementServiceMachineIpAddress = "not available"
-		}
-	}
-
-	if ($null -NE $cKmsHost -And $IsKeyManagementServiceMachine -GT 0) {
-		if ($null -NE $ExpireMsg) {CONOUT "`n    $ExpireMsg"}
+	if ($null -NE $cKmsServer) {
 		DetectKmsHost
 	}
 
@@ -12980,7 +13340,7 @@ function GetResult($strSLP, $strSLS, $strID)
 		DetectKmsClient
 	}
 
-	if ($null -EQ $cKmsHost) {
+	if ($null -EQ $cKmsServer) {
 		if ($null -NE $ExpireMsg) {CONOUT "`n    $ExpireMsg"}
 	}
 
@@ -12989,6 +13349,16 @@ function GetResult($strSLP, $strSLS, $strID)
 	}
 
 }
+
+function ParseList($strSLP, $strApp, $arrList)
+{
+	foreach ($entry in $arrList)
+	{
+		GetResult $strSLP $strApp $entry
+		CONOUT "$line3"
+		& $noAll
+	}
+}
 #endregion
 
 #region vNextDiag
@@ -13207,31 +13577,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #>
 
-function BoolToWStr($bVal) {
-	("TRUE", "FALSE")[!$bVal]
-}
-
-function InitializePInvoke {
-	$Marshal = [System.Runtime.InteropServices.Marshal]
-	$Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly((Get-Random), 'Run').DefineDynamicModule((Get-Random))
-
-	$Class = $Module.DefineType('NativeMethods', 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0)
-	$Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig')
-	$Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128)
-	$Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
-
-	if ($DllSubscription) {
-		$Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
-		$Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0)
-		[void]$Struct.DefineField('dwEnabled', [UInt32], 'Public')
-		[void]$Struct.DefineField('dwSku', [UInt32], 6)
-		[void]$Struct.DefineField('dwState', [UInt32], 6)
-		$SubStatus = $Struct.CreateType()
-	}
-
-	$Win32 = $Class.CreateType()
-}
-
 function InitializeDigitalLicenseCheck {
 	$CAB = [System.Reflection.Emit.CustomAttributeBuilder]
 
@@ -13286,36 +13631,29 @@ function PrintLastActivationHResult {
 }
 
 function PrintLastActivationTime {
-	$pdwLastTime = 0
+	$pqwLastTime = 0
 	$cbSize = 0
 
 	if ($Win32::SLGetWindowsInformation(
 		"Security-SPP-LastWindowsActivationTime",
 		[ref]$null,
 		[ref]$cbSize,
-		[ref]$pdwLastTime
+		[ref]$pqwLastTime
 	)) {
 		return $FALSE
 	}
 
-	$actTime = $Marshal::ReadInt64($pdwLastTime)
+	$actTime = $Marshal::ReadInt64($pqwLastTime)
 	if ($actTime -ne 0) {
 		CONOUT ("    LastActivationTime={0}" -f [DateTime]::FromFileTimeUtc($actTime).ToString("yyyy/MM/dd:HH:mm:ss"))
 	}
 
-	$Marshal::FreeHGlobal($pdwLastTime)
+	$Marshal::FreeHGlobal($pqwLastTime)
 	return $TRUE
 }
 
 function PrintIsWindowsGenuine {
 	$dwGenuine = 0
-	$ppwszGenuineStates = @(
-		"SL_GEN_STATE_IS_GENUINE",
-		"SL_GEN_STATE_INVALID_LICENSE",
-		"SL_GEN_STATE_TAMPERED",
-		"SL_GEN_STATE_OFFLINE",
-		"SL_GEN_STATE_LAST"
-	)
 
 	if ($Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)) {
 		return $FALSE
@@ -13412,6 +13750,126 @@ function ClicRun
 }
 #endregion
 
+#region clc
+function clcGetExpireKrn
+{
+	$tData = 0
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetWindowsInformation(
+		"Kernel-ExpirationDate",
+		[ref]$tData,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData -Or $tData -NE 3)
+	{
+		return $null
+	}
+
+	$year = $Marshal::ReadInt16($bData, 0)
+	if ($year -EQ 0 -Or $year -EQ 1601)
+	{
+		$rData = $null
+	}
+	else
+	{
+		$rData = '{0}/{1}/{2}:{3}:{4}:{5}' -f $year, $Marshal::ReadInt16($bData, 2), $Marshal::ReadInt16($bData, 4), $Marshal::ReadInt16($bData, 6), $Marshal::ReadInt16($bData, 8), $Marshal::ReadInt16($bData, 10)
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function clcGetExpireSys
+{
+	$kuser = $Marshal::ReadInt64((New-Object IntPtr(0x7FFE02C8)))
+
+	if ($kuser -EQ 0)
+	{
+		return $null
+	}
+
+	$rData = [DateTime]::FromFileTimeUTC($kuser).ToString('yyyy/MM/dd:HH:mm:ss')
+	return $rData
+}
+
+function clcGetLicensingState($dwState)
+{
+	if ($dwState -EQ 5) {
+		$dwState = 3
+	} elseif ($dwState -EQ 3 -Or $dwState -EQ 4 -Or $dwState -EQ 6) {
+		$dwState = 2
+	} elseif ($dwState -GT 6) {
+		$dwState = 4
+	}
+
+	$rData = '{0}' -f $ppwszLicensingStates[$dwState]
+	return $rData
+}
+
+function clcGetGenuineState($AppId)
+{
+	$dwGenuine = 0
+
+	if ($NT7) {
+		$ret = $Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)
+	} else {
+		$ret = $Win32::SLIsGenuineLocal([ref][Guid]$AppId, [ref]$dwGenuine, 0)
+	}
+
+	if ($ret)
+	{
+		$dwGenuine = 4
+	}
+
+	if ($dwGenuine -LT 5) {
+		$rData = '{0}' -f $ppwszGenuineStates[$dwGenuine]
+	} else {
+		$rData = $dwGenuine
+	}
+	return $rData
+}
+
+function ClcRun
+{
+	$prs = $script:primary[0]
+	if ($null -EQ $prs) {
+		return
+	}
+
+	$lState = clcGetLicensingState $prs.lst
+	$uState = clcGetGenuineState $winApp
+	$TbbKrn = clcGetExpireKrn
+	$TbbSys = clcGetExpireSys
+	if ($null -NE $TbbKrn) {
+		$ked = $TbbKrn
+	} elseif ($null -NE $TbbSys) {
+		$ked = $TbbSys
+	}
+
+	& $isAll
+	CONOUT "Client Licensing Check information:"
+
+	CONOUT ("    AppId={0}" -f $winApp)
+	if ($prs.ged) { CONOUT ("    GraceEndDate={0}" -f ([DateTime]::UtcNow.AddMinutes($prs.ged).ToString('yyyy/MM/dd:HH:mm:ss'))) }
+	if ($null -NE $ked) { CONOUT ("    KernelTimebombDate={0}" -f $ked) }
+	CONOUT ("    LastConsumptionReason=0x{0:x8}" -f $prs.lcr)
+	if ($prs.evl) { CONOUT ("    LicenseExpirationDate={0}" -f ([DateTime]::FromFileTimeUtc($prs.evl).ToString('yyyy/MM/dd:HH:mm:ss'))) }
+	CONOUT ("    LicenseState={0}" -f $lState)
+	CONOUT ("    PartialProductKey={0}" -f $prs.ppk)
+	CONOUT ("    ProductKeyType={0}" -f $prs.chn)
+	CONOUT ("    SkuId={0}" -f $prs.aid)
+	CONOUT ("    uxDifferentiator={0}" -f $prs.dff)
+	CONOUT ("    IsWindowsGenuine={0}" -f $uState)
+
+	CONOUT "$line3"
+	& $noAll
+}
+#endregion
+
 $Host.UI.RawUI.WindowTitle = "Check Activation Status"
 if ($All.IsPresent) {
 	$B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B;
@@ -13430,14 +13888,38 @@ $osls = "OfficeSoftwareProtectionService"
 $winApp = "55c92734-d682-4d71-983e-d6ec3f16059f"
 $o14App = "59a52881-a989-479d-af46-f275c6370663"
 $o15App = "0ff1ce15-a989-479d-af46-f275c6370663"
-$cSub = ($winbuild -GE 19041) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType")
+$cSub = ($winbuild -GE 26000) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType")
 $DllDigital = ($winbuild -GE 14393) -And (Test-Path "$SysPath\EditionUpgradeManagerObj.dll")
 $DllSubscription = ($winbuild -GE 14393) -And (Test-Path "$SysPath\Clipc.dll")
 $VLActTypes = @("All", "AD", "KMS", "Token")
+$OPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
+$SPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
 $SLKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
 $NSKeyPath = "HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
+$propPrd = 'Name', 'Description', 'TrustedTime', 'VLActivationType'
+$propPkey = 'PartialProductKey', 'Channel', 'DigitalPID', 'DigitalPID2'
+$propKMSServer = 'KeyManagementServiceCurrentCount', 'KeyManagementServiceTotalRequests', 'KeyManagementServiceFailedRequests', 'KeyManagementServiceUnlicensedRequests', 'KeyManagementServiceLicensedRequests', 'KeyManagementServiceOOBGraceRequests', 'KeyManagementServiceOOTGraceRequests', 'KeyManagementServiceNonGenuineGraceRequests', 'KeyManagementServiceNotificationRequests'
+$propKMSClient = 'CustomerPID', 'KeyManagementServiceName', 'KeyManagementServicePort', 'DiscoveredKeyManagementServiceName', 'DiscoveredKeyManagementServicePort', 'DiscoveredKeyManagementServiceIpAddress', 'VLActivationInterval', 'VLRenewalInterval', 'KeyManagementServiceLookupDomain'
+$propKMSVista  = 'CustomerPID', 'KeyManagementServiceName', 'VLActivationInterval', 'VLRenewalInterval'
+$propADBA = 'ADActivationObjectName', 'ADActivationObjectDN', 'ADActivationCsvlkPID', 'ADActivationCsvlkSkuID'
+$propAVMA = 'InheritedActivationId', 'InheritedActivationHostMachineName', 'InheritedActivationHostDigitalPid2', 'InheritedActivationActivationTime'
+$primary = @()
+$ppwszGenuineStates = @(
+	"SL_GEN_STATE_IS_GENUINE",
+	"SL_GEN_STATE_INVALID_LICENSE",
+	"SL_GEN_STATE_TAMPERED",
+	"SL_GEN_STATE_OFFLINE",
+	"SL_GEN_STATE_LAST"
+)
+$ppwszLicensingStates = @(
+	"SL_LICENSING_STATUS_UNLICENSED",
+	"SL_LICENSING_STATUS_LICENSED",
+	"SL_LICENSING_STATUS_IN_GRACE_PERIOD",
+	"SL_LICENSING_STATUS_NOTIFICATION",
+	"SL_LICENSING_STATUS_LAST"
+)
 
-'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ $false}
+'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ @()}
 
 $offsvc = "osppsvc"
 if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"}
@@ -13445,83 +13927,102 @@ if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"}
 try {gsv $winsvc -EA 1 | Out-Null; $WsppHook = 1} catch {$WsppHook = 0}
 try {gsv $offsvc -EA 1 | Out-Null; $OsppHook = 1} catch {$OsppHook = 0}
 
-if ($WsppHook -NE 0) {
-	try {sasv $winsvc -EA 1} catch {}
-	$cW1nd0ws  = DetectID $wslp $winApp
-	$c0ff1ce15 = DetectID $wslp $o15App
-	$c0ff1ce14 = DetectID $wslp $o14App
+if (Test-Path "$SysPath\sppc.dll") {
+	$SLdll = 'sppc.dll'
+} elseif (Test-Path "$SysPath\slc.dll") {
+	$SLdll = 'slc.dll'
+} else {
+	$WsppHook = 0
 }
 
 if ($OsppHook -NE 0) {
-	try {sasv $offsvc -EA 1} catch {}
-	$ospp15 = DetectID $oslp $o15App
-	$ospp14 = DetectID $oslp $o14App
+	$OLdll = (strGetRegistry $OPKeyPath "Path") + 'osppc.dll'
+	if (!(Test-Path "$OLdll")) {$OsppHook = 0}
 }
 
-if ($cW1nd0ws)
+if ($WsppHook -NE 0) {
+	if ($NT6 -And -Not $NT7 -And -Not $Admin) {
+		if ($null -EQ [Diagnostics.Process]::GetProcessesByName("$winsvc")[0].ProcessName) {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"}
+	} else {
+		try {sasv $winsvc -EA 1} catch {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"}
+	}
+}
+
+if ($WsppHook -NE 0) {
+	. InitializePInvoke $SLdll $false
+	$hSLC = 0
+	[void]$Win32::SLOpen([ref]$hSLC)
+
+	$cW1nd0ws  = SlGetInfoSLID $winApp
+	$c0ff1ce15 = SlGetInfoSLID $o15App
+	$c0ff1ce14 = SlGetInfoSLID $o14App
+}
+
+if ($cW1nd0ws.Count -GT 0)
 {
 	echoWindows
-	GetID $wslp $winApp | foreach -EA 1 {
-	GetResult $wslp $wsls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+	ParseList $wslp $winApp $cW1nd0ws
 }
 elseif ($NT6)
 {
 	echoWindows
-	CONOUT "`nError: product key not found."
+	CONOUT "Error: product key not found.`n"
 }
 
-if ($winbuild -GE 9200) {
-	. InitializePInvoke
+if ($NT6 -And -Not $NT8) {
+	ClcRun
+}
+
+if ($NT8) {
 	ClicRun
 }
 
-if ($c0ff1ce15 -Or $ospp15) {
-	CheckOhook
-}
-
 $doMSG = 1
 
-if ($c0ff1ce15)
+if ($c0ff1ce15.Count -GT 0)
 {
+	CheckOhook
 	echoOffice
-	GetID $wslp $o15App | foreach -EA 1 {
-	GetResult $wslp $wsls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+	ParseList $wslp $o15App $c0ff1ce15
 }
 
-if ($c0ff1ce14)
+if ($c0ff1ce14.Count -GT 0)
 {
 	echoOffice
-	GetID $wslp $o14App | foreach -EA 1 {
-	GetResult $wslp $wsls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+	ParseList $wslp $o14App $c0ff1ce14
 }
 
-if ($ospp15)
-{
-	echoOffice
-	GetID $oslp $o15App | foreach -EA 1 {
-	GetResult $oslp $osls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+if ($hSLC) {
+	[void]$Win32::SLClose($hSLC)
 }
 
-if ($ospp14)
+if ($OsppHook -NE 0) {
+	try {sasv $offsvc -EA 1} catch {$OsppHook = 0; CONOUT "`nError: failed to start $offsvc Service.`n"}
+}
+
+if ($OsppHook -NE 0) {
+	. InitializePInvoke "$OLdll" $true
+	$hSLC = 0
+	[void]$Win32::SLOpen([ref]$hSLC)
+
+	$ospp15 = SlGetInfoSLID $o15App
+	$ospp14 = SlGetInfoSLID $o14App
+}
+
+if ($ospp15.Count -GT 0)
 {
 	echoOffice
-	GetID $oslp $o14App | foreach -EA 1 {
-	GetResult $oslp $osls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+	ParseList $oslp $o15App $ospp15
+}
+
+if ($ospp14.Count -GT 0)
+{
+	echoOffice
+	ParseList $oslp $o14App $ospp14
+}
+
+if ($hSLC) {
+	[void]$Win32::SLClose($hSLC)
 }
 
 if ($NT7) {
diff --git a/MAS/Separate-Files-Version/Check_Activation_Status.cmd b/MAS/Separate-Files-Version/Check_Activation_Status.cmd
index f15f36e..fd72a3f 100644
--- a/MAS/Separate-Files-Version/Check_Activation_Status.cmd
+++ b/MAS/Separate-Files-Version/Check_Activation_Status.cmd
@@ -118,6 +118,7 @@ $IID = $IID.IsPresent -Or $Dlv.IsPresent
 
 $NT6 = $winbuild -GE 6000
 $NT7 = $winbuild -GE 7600
+$NT8 = $winbuild -GE 9200
 $NT9 = $winbuild -GE 9600
 
 $Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
@@ -193,55 +194,375 @@ function CheckOhook
 	& $noAll
 }
 
-#region WMI
-function DetectID($strSLP, $strAppId)
-{
-	$ppk = (" AND PartialProductKey <> NULL)", ")")[$All.IsPresent]
-	$fltr = "SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId'"
-	$clause = $fltr + $ppk
-	$sWmi = [wmisearcher]$clause
-	$sWmi.Options.Rewindable = $false
-	return ($sWmi.Get().Count -GT 0)
+#region SSSS
+function BoolToWStr($bVal) {
+	("TRUE", "FALSE")[!$bVal]
 }
 
-function GetID($strSLP, $strAppId)
-{
-	$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
-	$IDs = [Collections.ArrayList]@()
-	$isAdd = (" AND LicenseDependsOn <> NULL)", ")")[$NT5]
-	$noAdd = " AND LicenseDependsOn IS NULL)"
-	$query = "SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId' AND PartialProductKey"
+function InitializePInvoke($LaDll, $bOffice) {
+	$Marshal = [System.Runtime.InteropServices.Marshal]
+	$Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly((Get-Random), 'Run').DefineDynamicModule((Get-Random), $False)
+	$SLApp = $NT7 -Or $bOffice -Or ($LaDll -EQ 'sppc.dll' -And [Diagnostics.FileVersionInfo]::GetVersionInfo("$SysPath\sppc.dll").FilePrivatePart -GE 16501)
 
-	if ($All.IsPresent) {
-		$fltr = $query + " IS NULL"
-		$clause = $fltr + $isAdd
-		$sWmi = [wmisearcher]$clause
-		$sWmi.Options.Rewindable = $false
-		try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
-		if (-Not $NT5) {
-		$clause = $fltr + $noAdd
-		$sWmi = [wmisearcher]$clause
-		$sWmi.Options.Rewindable = $false
-		try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
+	$Win32 = $null
+	$Class = $Module.DefineType((Get-Random), 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0)
+	$Class.DefinePInvokeMethod('SLClose', $LaDll, 22, 1, [Int32], @([IntPtr]), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLOpen', $LaDll, 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGenerateOfflineInstallationId', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetSLIDList', $LaDll, 22, 1, [Int32], @([IntPtr], [UInt32], [Guid].MakeByRefType(), [UInt32], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetLicensingStatusInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [Guid].MakeByRefType(), [IntPtr], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetPKeyInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetProductSkuInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	$Class.DefinePInvokeMethod('SLGetServiceInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	if ($SLApp) {
+		$Class.DefinePInvokeMethod('SLGetApplicationInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+	}
+	if ($bOffice) {
+		$Win32 = $Class.CreateType()
+		return
+	}
+	if ($NT6) {
+		$Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+		$Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+		$Class.DefinePInvokeMethod('SLIsGenuineLocal', 'slwga.dll', 22, 1, [Int32], @([Guid].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr]), 1, 3).SetImplementationFlags(128)
+	}
+	if ($NT7) {
+		$Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig')
+	}
+
+	if ($DllSubscription) {
+		$Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
+		$Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0)
+		[void]$Struct.DefineField('dwEnabled', [UInt32], 'Public')
+		[void]$Struct.DefineField('dwSku', [UInt32], 6)
+		[void]$Struct.DefineField('dwState', [UInt32], 6)
+		$SubStatus = $Struct.CreateType()
+	}
+
+	$Win32 = $Class.CreateType()
+}
+
+function SlGetInfoIID($SkuId)
+{
+	$bData = 0
+
+	if ($Win32::SLGenerateOfflineInstallationId(
+		$hSLC,
+		[ref][Guid]$SkuId,
+		[ref]$bData
+	))
+	{
+		return $null
+	}
+
+	$rData = $Marshal::PtrToStringUni($bData)
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoSku($SkuId, $Value)
+{
+	$tData = 0
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetProductSkuInformation(
+		$hSLC,
+		[ref][Guid]$SkuId,
+		$Value,
+		[ref]$tData,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $null
+	}
+
+	if ($tData -EQ 1)
+	{
+		$rData = $Marshal::PtrToStringUni($bData)
+	}
+	elseif ($tData -EQ 4)
+	{
+		$rData = $Marshal::ReadInt32($bData)
+	}
+	elseif ($tData -EQ 3 -And $cData -EQ 8)
+	{
+		$rData = $Marshal::ReadInt64($bData)
+	}
+	else
+	{
+		$rData = $null
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoService($Value)
+{
+	$tData = 0
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetServiceInformation(
+		$hSLC,
+		$Value,
+		[ref]$tData,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $null
+	}
+
+	if ($tData -EQ 1)
+	{
+		$rData = $Marshal::PtrToStringUni($bData)
+	}
+	elseif ($tData -EQ 4)
+	{
+		$rData = $Marshal::ReadInt32($bData)
+	}
+	elseif ($tData -EQ 3 -And $cData -EQ 8)
+	{
+		$rData = $Marshal::ReadInt64($bData)
+	}
+	else
+	{
+		$rData = $null
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoApp($AppId, $Value)
+{
+	$tData = 0
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetApplicationInformation(
+		$hSLC,
+		[ref][Guid]$AppId,
+		$Value,
+		[ref]$tData,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $null
+	}
+
+	if ($tData -EQ 1)
+	{
+		$rData = $Marshal::PtrToStringUni($bData)
+	}
+	elseif ($tData -EQ 4)
+	{
+		$rData = $Marshal::ReadInt32($bData)
+	}
+	elseif ($tData -EQ 3 -And $cData -EQ 8)
+	{
+		$rData = $Marshal::ReadInt64($bData)
+	}
+	else
+	{
+		$rData = $null
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoSvcApp($strApp, $Value)
+{
+	if ($SLApp)
+	{
+		$rData = SlGetInfoApp $strApp $Value
+	}
+	else
+	{
+		$rData = SlGetInfoService $Value
+	}
+	return $rData
+}
+
+function SlGetInfoPKey($PkeyId, $Value)
+{
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetPKeyInformation(
+		$hSLC,
+		[ref][Guid]$PKeyId,
+		$Value,
+		[ref]$null,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $null
+	}
+
+	$rData = $Marshal::PtrToStringUni($bData)
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoLicensing($AppId, $SkuId)
+{
+	$LicenseStatus = 0
+	$GracePeriodRemaining = 0
+	$hrReason = 0
+	$EvaluationEndDate = 0
+
+	$cStatus = 0
+	$pStatus = 0
+
+	$ret = $Win32::SLGetLicensingStatusInformation(
+		$hSLC,
+		[ref][Guid]$AppId,
+		[ref][Guid]$SkuId,
+		0,
+		[ref]$cStatus,
+		[ref]$pStatus
+	)
+
+	if ($ret -Or !$cStatus)
+	{
+		return
+	}
+
+	[IntPtr]$ppStatus = [Int64]$pStatus + [Int64]40 * ($cStatus - 1)
+	$eStatus = $Marshal::ReadInt32($ppStatus, 16)
+	$GracePeriodRemaining = $Marshal::ReadInt32($ppStatus, 20)
+	$hrReason = $Marshal::ReadInt32($ppStatus, 28)
+	$EvaluationEndDate = $Marshal::ReadInt64($ppStatus, 32)
+
+	if ($eStatus -EQ 3)
+	{
+		$eStatus = 5
+	}
+	if ($eStatus -EQ 2)
+	{
+		if ($hrReason -EQ 0x4004F00D)
+		{
+			$eStatus = 3
+		}
+		elseif ($hrReason -EQ 0x4004F065)
+		{
+			$eStatus = 4
+		}
+		elseif ($hrReason -EQ 0x4004FC06)
+		{
+			$eStatus = 6
 		}
 	}
+	$LicenseStatus = $eStatus
 
-	$fltr = $query + " <> NULL"
-	$clause = $fltr + $isAdd
-	$sWmi = [wmisearcher]$clause
-	$sWmi.Options.Rewindable = $false
-	try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
-	if (-Not $NT5) {
-	$clause = $fltr + $noAdd
-	$sWmi = [wmisearcher]$clause
-	$sWmi.Options.Rewindable = $false
-	try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
+	$Marshal::FreeHGlobal($pStatus)
+	return
+}
+
+function SlCheckInfo($SkuId, $Value)
+{
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetProductSkuInformation(
+		$hSLC,
+		[ref][Guid]$SkuId,
+		$Value,
+		[ref]$null,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData)
+	{
+		return $false
 	}
 
-	return $IDs
+	if ($Value -EQ "pkeyId")
+	{
+		$rData = $Marshal::PtrToStringUni($bData)
+	}
+	else
+	{
+		$rData = $true
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function SlGetInfoSLID($AppId)
+{
+	$cReturnIds = 0
+	$pReturnIds = 0
+
+	$ret = $Win32::SLGetSLIDList(
+		$hSLC,
+		0,
+		[ref][Guid]$AppId,
+		1,
+		[ref]$cReturnIds,
+		[ref]$pReturnIds
+	)
+
+	if ($ret -Or !$cReturnIds)
+	{
+		return
+	}
+
+	$a1List = @()
+	$a2List = @()
+	$a3List = @()
+	$a4List = @()
+
+	foreach ($i in 0..($cReturnIds - 1))
+	{
+		$bytes = New-Object byte[] 16
+		$Marshal::Copy([Int64]$pReturnIds + [Int64]16 * $i, $bytes, 0, 16)
+		$actid = ([Guid]$bytes).Guid
+		$gPPK = SlCheckInfo $actid "pkeyId"
+		$gAdd = SlCheckInfo $actid "DependsOn"
+		if ($All.IsPresent) {
+			if (!$gPPK -And $gAdd) { $a1List += @{id = $actid; pk = $null; ex = $true} }
+			if (!$gPPK -And !$gAdd) { $a2List += @{id = $actid; pk = $null; ex = $false} }
+		}
+		if ($gPPK -And $gAdd) { $a3List += @{id = $actid; pk = $gPPK; ex = $true} }
+		if ($gPPK -And !$gAdd) { $a4List += @{id = $actid; pk = $gPPK; ex = $false} }
+	}
+
+	$Marshal::FreeHGlobal($pReturnIds)
+	return ($a1List + $a2List + $a3List + $a4List)
 }
 
 function DetectSubscription {
+	try
+	{
+		$objSvc = New-Object PSObject
+		$wmiSvc = [wmisearcher]"SELECT SubscriptionType, SubscriptionStatus, SubscriptionEdition, SubscriptionExpiry FROM SoftwareLicensingService"
+		$wmiSvc.Options.Rewindable = $false
+		$wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { $objSvc | Add-Member 8 $_.Name $_.Value }
+		$wmiSvc.Dispose()
+	}
+	catch
+	{
+		return
+	}
+
 	if ($null -EQ $objSvc.SubscriptionType -Or $objSvc.SubscriptionType -EQ 120) {
 		return
 	}
@@ -273,161 +594,188 @@ function DetectSubscription {
 	}
 
 	CONOUT "`nSubscription information:"
-	CONOUT "    Edition: $SubMsgEdition"
 	CONOUT "    Type   : $SubMsgType"
 	CONOUT "    Status : $SubMsgStatus"
+	CONOUT "    Edition: $SubMsgEdition"
 	CONOUT "    Expiry : $SubMsgExpiry"
 }
 
 function DetectAdbaClient
 {
+	$propADBA | foreach { set $_ (SlGetInfoSku $ID $_) }
 	CONOUT "`nAD Activation client information:"
 	CONOUT "    Object Name: $ADActivationObjectName"
 	CONOUT "    Domain Name: $ADActivationObjectDN"
-	CONOUT "    CSVLK Extended PID: $ADActivationCsvlkPid"
-	CONOUT "    CSVLK Activation ID: $ADActivationCsvlkSkuId"
+	CONOUT "    CSVLK Extended PID: $ADActivationCsvlkPID"
+	CONOUT "    CSVLK Activation ID: $ADActivationCsvlkSkuID"
 }
 
 function DetectAvmClient
 {
+	$propAVMA | foreach { set $_ (SlGetInfoSku $ID $_) }
 	CONOUT "`nAutomatic VM Activation client information:"
-	if (-Not [String]::IsNullOrEmpty($IAID)) {
-		CONOUT "    Guest IAID: $IAID"
+	if (-Not [String]::IsNullOrEmpty($InheritedActivationId)) {
+		CONOUT "    Guest IAID: $InheritedActivationId"
 	} else {
 		CONOUT "    Guest IAID: Not Available"
 	}
-	if (-Not [String]::IsNullOrEmpty($AutomaticVMActivationHostMachineName)) {
-		CONOUT "    Host machine name: $AutomaticVMActivationHostMachineName"
+	if (-Not [String]::IsNullOrEmpty($InheritedActivationHostMachineName)) {
+		CONOUT "    Host machine name: $InheritedActivationHostMachineName"
 	} else {
 		CONOUT "    Host machine name: Not Available"
 	}
-	if ($AutomaticVMActivationLastActivationTime.Substring(0,4) -NE "1601") {
-		$EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($AutomaticVMActivationLastActivationTime),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt')
-		CONOUT "    Activation time: $EED UTC"
-	} else {
-		CONOUT "    Activation time: Not Available"
-	}
-	if (-Not [String]::IsNullOrEmpty($AutomaticVMActivationHostDigitalPid2)) {
-		CONOUT "    Host Digital PID2: $AutomaticVMActivationHostDigitalPid2"
+	if (-Not [String]::IsNullOrEmpty($InheritedActivationHostDigitalPid2)) {
+		CONOUT "    Host Digital PID2: $InheritedActivationHostDigitalPid2"
 	} else {
 		CONOUT "    Host Digital PID2: Not Available"
 	}
+	if ($InheritedActivationActivationTime) {
+		$IAAT = [DateTime]::FromFileTime($InheritedActivationActivationTime).ToString('yyyy-MM-dd hh:mm:ss tt')
+		CONOUT "    Activation time: $IAAT"
+	} else {
+		CONOUT "    Activation time: Not Available"
+	}
 }
 
 function DetectKmsHost
 {
+	$IsKeyManagementService = SlGetInfoSvcApp $strApp 'IsKeyManagementService'
+	if (-Not $IsKeyManagementService) {
+		return
+	}
+	if ($null -NE $ExpireMsg) {CONOUT "`n    $ExpireMsg"}
+
 	if ($Vista -Or $NT5) {
-		$KeyManagementServiceListeningPort = strGetRegistry $SLKeyPath "KeyManagementServiceListeningPort"
-		$KeyManagementServiceDnsPublishing = strGetRegistry $SLKeyPath "DisableDnsPublishing"
-		$KeyManagementServiceLowPriority = strGetRegistry $SLKeyPath "EnableKmsLowPriority"
-		if (-Not $KeyManagementServiceDnsPublishing) {$KeyManagementServiceDnsPublishing = "TRUE"}
-		if (-Not $KeyManagementServiceLowPriority) {$KeyManagementServiceLowPriority = "FALSE"}
+		$regk = $SLKeyPath
+	} elseif ($strSLP -EQ $oslp) {
+		$regk = $OPKeyPath
 	} else {
-		$KeyManagementServiceListeningPort = $objSvc.KeyManagementServiceListeningPort
-		$KeyManagementServiceDnsPublishing = $objSvc.KeyManagementServiceDnsPublishing
-		$KeyManagementServiceLowPriority = $objSvc.KeyManagementServiceLowPriority
+		$regk = $SPKeyPath
+	}
+	$KMSListening = strGetRegistry $regk "KeyManagementServiceListeningPort"
+	$KMSPublishing = strGetRegistry $regk "DisableDnsPublishing"
+	$KMSPriority = strGetRegistry $regk "EnableKmsLowPriority"
+
+	if (-Not $KMSListening) {$KMSListening = 1688}
+	if (-Not $KMSPublishing) {$KMSPublishing = "TRUE"} else {$KMSPublishing = BoolToWStr (!$KMSPublishing)}
+	if (-Not $KMSPriority) {$KMSPriority = "FALSE"} else {$KMSPriority = BoolToWStr $KMSPriority}
+
+	if ($KMSPublishing -EQ "TRUE") {$KMSPublishing = "Enabled"} else {$KMSPublishing = "Disabled"}
+	if ($KMSPriority -EQ "TRUE") {$KMSPriority = "Low"} else {$KMSPriority = "Normal"}
+
+	if ($SLApp)
+	{
+		$propKMSServer | foreach { set $_ (SlGetInfoApp $strApp $_) }
+	}
+	else
+	{
+		$propKMSServer | foreach { set $_ (SlGetInfoService $_) }
 	}
 
-	if (-Not $KeyManagementServiceListeningPort) {$KeyManagementServiceListeningPort = 1688}
-	if ($KeyManagementServiceDnsPublishing -EQ "TRUE") {
-		$KeyManagementServiceDnsPublishing = "Enabled"
-	} else {
-		$KeyManagementServiceDnsPublishing = "Disabled"
-	}
-	if ($KeyManagementServiceLowPriority -EQ "TRUE") {
-		$KeyManagementServiceLowPriority = "Low"
-	} else {
-		$KeyManagementServiceLowPriority = "Normal"
-	}
+	$KMSRequests = $KeyManagementServiceTotalRequests
+	$NoRequests = ($null -EQ $KMSRequests) -Or ($KMSRequests -EQ -1) -Or ($KMSRequests -EQ 4294967295)
 
 	CONOUT "`nKey Management Service host information:"
 	CONOUT "    Current count: $KeyManagementServiceCurrentCount"
-	CONOUT "    Listening on Port: $KeyManagementServiceListeningPort"
-	CONOUT "    DNS publishing: $KeyManagementServiceDnsPublishing"
-	CONOUT "    KMS priority: $KeyManagementServiceLowPriority"
-	if (-Not [String]::IsNullOrEmpty($KeyManagementServiceTotalRequests)) {
-		CONOUT "`nKey Management Service cumulative requests received from clients:"
-		CONOUT "    Total: $KeyManagementServiceTotalRequests"
-		CONOUT "    Failed: $KeyManagementServiceFailedRequests"
-		CONOUT "    Unlicensed: $KeyManagementServiceUnlicensedRequests"
-		CONOUT "    Licensed: $KeyManagementServiceLicensedRequests"
-		CONOUT "    Initial grace period: $KeyManagementServiceOOBGraceRequests"
-		CONOUT "    Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests"
-		CONOUT "    Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests"
-		if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT "    Notification: $KeyManagementServiceNotificationRequests"}
+	CONOUT "    Listening on Port: $KMSListening"
+	CONOUT "    DNS publishing: $KMSPublishing"
+	CONOUT "    KMS priority: $KMSPriority"
+	if ($NoRequests) {
+		return
 	}
+	CONOUT "`nKey Management Service cumulative requests received from clients:"
+	CONOUT "    Total: $KeyManagementServiceTotalRequests"
+	CONOUT "    Failed: $KeyManagementServiceFailedRequests"
+	CONOUT "    Unlicensed: $KeyManagementServiceUnlicensedRequests"
+	CONOUT "    Licensed: $KeyManagementServiceLicensedRequests"
+	CONOUT "    Initial grace period: $KeyManagementServiceOOBGraceRequests"
+	CONOUT "    Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests"
+	CONOUT "    Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests"
+	if ($null -NE $KeyManagementServiceNotificationRequests) {CONOUT "    Notification: $KeyManagementServiceNotificationRequests"}
 }
 
 function DetectKmsClient
 {
-	if ($null -NE $VLActivationTypeEnabled) {CONOUT "Configured Activation Type: $($VLActTypes[$VLActivationTypeEnabled])"}
+	if ($strSLP -EQ $wslp -And $NT8)
+	{
+		$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp + '\' + $ID) "VLActivationType"
+		if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp) "VLActivationType"}
+		if ($null -EQ $VLType) {$VLType = strGetRegistry ($SPKeyPath) "VLActivationType"}
+		if ($null -EQ $VLType -Or $VLType -GT 3) {$VLType = 0}
+	}
+	if ($null -NE $VLType) {CONOUT "Configured Activation Type: $($VLActTypes[$VLType])"}
+
 	CONOUT "`r"
 	if ($LicenseStatus -NE 1) {
 		CONOUT "Please activate the product in order to update KMS client information values."
 		return
 	}
 
-	if ($Vista) {
-		$KeyManagementServicePort = strGetRegistry $SLKeyPath "KeyManagementServicePort"
-		$DiscoveredKeyManagementServiceMachineName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName"
-		$DiscoveredKeyManagementServiceMachinePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort"
+	if ($NT7 -Or $strSLP -EQ $oslp) {
+		$propKMSClient | foreach { set $_ (SlGetInfoSku $ID $_) }
+		if ($strSLP -EQ $oslp) {$regk = $OPKeyPath} else {$regk = $SPKeyPath}
+		$KMSCaching = strGetRegistry $regk "DisableKeyManagementServiceHostCaching"
+		if (-Not $KMSCaching) {$KMSCaching = "TRUE"} else {$KMSCaching = BoolToWStr (!$KMSCaching)}
 	}
 
-	if ([String]::IsNullOrEmpty($KeyManagementServiceMachine)) {
+	"ClientMachineID" | foreach { set $_ (SlGetInfoService $_) }
+
+	if ($Vista) {
+		$propKMSVista | foreach { set $_ (SlGetInfoService $_) }
+		$KeyManagementServicePort = strGetRegistry $SLKeyPath "KeyManagementServicePort"
+		$DiscoveredKeyManagementServiceName = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServiceName"
+		$DiscoveredKeyManagementServicePort = strGetRegistry $NSKeyPath "DiscoveredKeyManagementServicePort"
+	}
+
+	if ([String]::IsNullOrEmpty($KeyManagementServiceName)) {
 		$KmsReg = $null
 	} else {
 		if (-Not $KeyManagementServicePort) {$KeyManagementServicePort = 1688}
-		$KmsReg = "Registered KMS machine name: ${KeyManagementServiceMachine}:${KeyManagementServicePort}"
+		$KmsReg = "Registered KMS machine name: ${KeyManagementServiceName}:${KeyManagementServicePort}"
 	}
 
-	if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceMachineName)) {
+	if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceName)) {
 		$KmsDns = "DNS auto-discovery: KMS name not available"
 		if ($Vista -And -Not $Admin) {$KmsDns = "DNS auto-discovery: Run the script as administrator to retrieve info"}
 	} else {
-		if (-Not $DiscoveredKeyManagementServiceMachinePort) {$DiscoveredKeyManagementServiceMachinePort = 1688}
-		$KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceMachineName}:${DiscoveredKeyManagementServiceMachinePort}"
+		if (-Not $DiscoveredKeyManagementServicePort) {$DiscoveredKeyManagementServicePort = 1688}
+		$KmsDns = "KMS machine name from DNS: ${DiscoveredKeyManagementServiceName}:${DiscoveredKeyManagementServicePort}"
 	}
 
-	if ($null -NE $objSvc.KeyManagementServiceHostCaching) {
-		if ($objSvc.KeyManagementServiceHostCaching -EQ "TRUE") {
-			$KeyManagementServiceHostCaching = "Enabled"
-		} else {
-			$KeyManagementServiceHostCaching = "Disabled"
+	if ($null -NE $KMSCaching) {
+		if ($KMSCaching -EQ "TRUE") {$KMSCaching = "Enabled"} else {$KMSCaching = "Disabled"}
+	}
+
+	if ($strSLP -EQ $wslp -And $NT9) {
+		if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceIpAddress)) {
+			$DiscoveredKeyManagementServiceIpAddress = "not available"
 		}
 	}
 
 	CONOUT "Key Management Service client information:"
-	CONOUT "    Client Machine ID (CMID): $($objSvc.ClientMachineID)"
+	CONOUT "    Client Machine ID (CMID): $ClientMachineID"
 	if ($null -EQ $KmsReg) {
 		CONOUT "    $KmsDns"
 		CONOUT "    Registered KMS machine name: KMS name not available"
 	} else {
 		CONOUT "    $KmsReg"
 	}
-	if ($null -NE $DiscoveredKeyManagementServiceMachineIpAddress) {CONOUT "    KMS machine IP address: $DiscoveredKeyManagementServiceMachineIpAddress"}
-	CONOUT "    KMS machine extended PID: $KeyManagementServiceProductKeyID"
+	if ($null -NE $DiscoveredKeyManagementServiceIpAddress) {CONOUT "    KMS machine IP address: $DiscoveredKeyManagementServiceIpAddress"}
+	CONOUT "    KMS machine extended PID: $CustomerPID"
 	CONOUT "    Activation interval: $VLActivationInterval minutes"
 	CONOUT "    Renewal interval: $VLRenewalInterval minutes"
-	if ($null -NE $KeyManagementServiceHostCaching) {CONOUT "    KMS host caching: $KeyManagementServiceHostCaching"}
+	if ($null -NE $KMSCaching) {CONOUT "    KMS host caching: $KMSCaching"}
 	if (-Not [String]::IsNullOrEmpty($KeyManagementServiceLookupDomain)) {CONOUT "    KMS SRV record lookup domain: $KeyManagementServiceLookupDomain"}
 }
 
-function GetResult($strSLP, $strSLS, $strID)
+function GetResult($strSLP, $strApp, $entry)
 {
-	try
-	{
-		$objPrd = [wmisearcher]"SELECT * FROM $strSLP WHERE ID='$strID'"
-		$objPrd.Options.Rewindable = $false
-		$objPrd.Get() | select -Expand Properties -EA 0 | foreach { if (-Not [String]::IsNullOrEmpty($_.Value)) {set $_.Name $_.Value} }
-		$objPrd.Dispose()
-	}
-	catch
-	{
-		return
-	}
+	$ID = $entry.id
+	$propPrd | foreach { set $_ (SlGetInfoSku $ID $_) }
+	. SlGetInfoLicensing $strApp $ID
 
-	$winID = ($ApplicationID -EQ $winApp)
-	$winPR = ($winID -And -Not $LicenseIsAddon)
+	$winID = ($strApp -EQ $winApp)
+	$winPR = ($winID -And -Not $entry.ex)
 	$Vista = ($winID -And $NT6 -And -Not $NT7)
 	$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
 	$reapp = ("Windows", "App")[!$winID]
@@ -437,16 +785,15 @@ function GetResult($strSLP, $strSLS, $strID)
 	if ($Description | Select-String "TIMEBASED_") {$cTblClient = 1; $_mTag = "Timebased"}
 	if ($Description | Select-String "VIRTUAL_MACHINE_ACTIVATION") {$cAvmClient = 1; $_mTag = "Automatic VM"}
 	if ($null -EQ $cKmsClient) {
-		if ($Description | Select-String "VOLUME_KMS") {$cKmsHost = 1}
+		if ($Description | Select-String "VOLUME_KMS") {$cKmsServer = 1}
 	}
 
 	$_gpr = [Math]::Round($GracePeriodRemaining/1440)
 	if ($_gpr -GT 0) {
-		$_xpr = [DateTime]::Now.addMinutes($GracePeriodRemaining).ToString('yyyy-MM-dd hh:mm:ss tt')
+		$_xpr = [DateTime]::Now.AddMinutes($GracePeriodRemaining).ToString('yyyy-MM-dd hh:mm:ss tt')
 	}
 
-	if ($null -EQ $LicenseStatusReason) {$LicenseStatusReason = -1}
-	$LicenseReason = '0x{0:X}' -f $LicenseStatusReason
+	$LicenseReason = '0x{0:X}' -f $hrReason
 	$LicenseMsg = "Time remaining: $GracePeriodRemaining minute(s) ($_gpr day(s))"
 	if ($LicenseStatus -EQ 0) {
 		$LicenseInf = "Unlicensed"
@@ -454,8 +801,8 @@ function GetResult($strSLP, $strSLS, $strID)
 	}
 	if ($LicenseStatus -EQ 1) {
 		$LicenseInf = "Licensed"
-		$LicenseMsg = $null
 		if ($GracePeriodRemaining -EQ 0) {
+			$LicenseMsg = $null
 			$ExpireMsg = "The $prmnt is permanently activated."
 		} else {
 			$LicenseMsg = "$_mTag activation expiration: $GracePeriodRemaining minute(s) ($_gpr day(s))"
@@ -490,24 +837,54 @@ function GetResult($strSLP, $strSLS, $strID)
 		if ($null -NE $_xpr) {$ExpireMsg = "Extended grace period ends $_xpr"}
 	}
 
-	if ($winPR -And $PartialProductKey -And -Not $NT9) {
-		$dp4 = strGetRegistry "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion" "DigitalProductId4"
-		if ($null -NE $dp4) {
-			$ProductKeyChannel = ([System.Text.Encoding]::Unicode.GetString($dp4, 1016, 128)).Trim([char]$null)
+	$pkid = $entry.pk
+	if ($null -NE $pkid) {
+		$propPkey | foreach { set $_ (SlGetInfoPKey $pkid $_) }
+	}
+
+	if ($winPR -And $null -NE $PartialProductKey -And -Not $NT8) {
+		$uxd = SlGetInfoSku $ID 'UXDifferentiator'
+		$script:primary += @{
+			aid = $ID;
+			ppk = $PartialProductKey;
+			chn = $Channel;
+			lst = $LicenseStatus;
+			lcr = $hrReason;
+			ged = $GracePeriodRemaining;
+			evl = $EvaluationEndDate;
+			dff = $uxd
 		}
 	}
 
-	if ($winPR -And $Dlv -And $NT7 -And $null -EQ $RemainingAppReArmCount) {
-		try
+	if ($IID -And $null -NE $PartialProductKey) {
+		$OfflineInstallationId = SlGetInfoIID $ID
+	}
+
+	if ($Dlv) {
+		if ($strSLP -EQ $wslp -And $NT8)
 		{
-			$tmp = [wmisearcher]"SELECT RemainingWindowsReArmCount FROM $strSLS"
-			$tmp.Options.Rewindable = $false
-			$tmp.Get() | select -Expand Properties -EA 0 | foreach {set $_.Name $_.Value}
-			$tmp.Dispose()
+			$RemainingSkuReArmCount = SlGetInfoSku $ID 'RemainingRearmCount'
+			$RemainingAppReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount'
 		}
-		catch
+		else
 		{
+			if (($winID -And $NT7) -Or $strSLP -EQ $oslp)
+			{
+				$RemainingSLReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount'
+			}
+			else
+			{
+				$RemainingSLReArmCount = SlGetInfoService 'RearmCount'
+			}
 		}
+		if ($null -EQ $TrustedTime)
+		{
+			$TrustedTime = SlGetInfoSvcApp $strApp 'TrustedTime'
+		}
+	}
+
+	if ($Dlv -Or $All.IsPresent) {
+		$gPHN = SlCheckInfo $ID "msft:sl/EUL/PHONE/PUBLIC"
 	}
 
 	$add_on = $Name.IndexOf("add-on for", 5)
@@ -516,73 +893,56 @@ function GetResult($strSLP, $strSLS, $strID)
 	if ($add_on -EQ -1) {CONOUT "Name: $Name"} else {CONOUT "Name: $($Name.Substring(0, $add_on + 7))"}
 	CONOUT "Description: $Description"
 	CONOUT "Activation ID: $ID"
-	if ($null -NE $ProductKeyID) {CONOUT "Extended PID: $ProductKeyID"}
-	if ($null -NE $ProductKeyID2 -And $Dlv) {CONOUT "Product ID: $ProductKeyID2"}
+	if ($null -NE $DigitalPID) {CONOUT "Extended PID: $DigitalPID"}
+	if ($null -NE $DigitalPID2 -And $Dlv) {CONOUT "Product ID: $DigitalPID2"}
 	if ($null -NE $OfflineInstallationId -And $IID) {CONOUT "Installation ID: $OfflineInstallationId"}
-	if ($null -NE $ProductKeyChannel) {CONOUT "Product Key Channel: $ProductKeyChannel"}
+	if ($null -NE $Channel) {CONOUT "Product Key Channel: $Channel"}
 	if ($null -NE $PartialProductKey) {CONOUT "Partial Product Key: $PartialProductKey"}
 	CONOUT "License Status: $LicenseInf"
 	if ($null -NE $LicenseMsg) {CONOUT "$LicenseMsg"}
-	if ($LicenseStatus -NE 0 -And $EvaluationEndDate.Substring(0,4) -NE "1601") {
-		$EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($EvaluationEndDate),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt')
+	if ($LicenseStatus -NE 0 -And $EvaluationEndDate) {
+		$EED = [DateTime]::FromFileTimeUtc($EvaluationEndDate).ToString('yyyy-MM-dd hh:mm:ss tt')
 		CONOUT "Evaluation End Date: $EED UTC"
 	}
+	if ($LicenseStatus -NE 1 -And $null -NE $gPHN) {
+		$gPHN = $gPHN.ToString()
+		CONOUT "Phone activatable: $gPHN"
+	}
 	if ($Dlv) {
-		if ($null -NE $RemainingWindowsReArmCount) {
-			CONOUT "Remaining Windows rearm count: $RemainingWindowsReArmCount"
+		if ($null -NE $RemainingSLReArmCount) {
+			CONOUT "Remaining $reapp rearm count: $RemainingSLReArmCount"
 		}
-		if ($null -NE $RemainingSkuReArmCount -And $RemainingSkuReArmCount -NE 4294967295) {
+		if ($null -NE $RemainingSkuReArmCount) {
 			CONOUT "Remaining $reapp rearm count: $RemainingAppReArmCount"
 			CONOUT "Remaining SKU rearm count: $RemainingSkuReArmCount"
 		}
-		if ($null -NE $TrustedTime -And $LicenseStatus -NE 0) {
-			$TTD = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($TrustedTime),$null,32).ToString('yyyy-MM-dd hh:mm:ss tt')
+		if ($LicenseStatus -NE 0 -And $TrustedTime) {
+			$TTD = [DateTime]::FromFileTime($TrustedTime).ToString('yyyy-MM-dd hh:mm:ss tt')
 			CONOUT "Trusted time: $TTD"
 		}
 	}
-	if ($LicenseStatus -EQ 0) {
+	if ($null -EQ $PartialProductKey) {
 		return
 	}
 
-	if ($strSLP -EQ $wslp -And $null -NE $PartialProductKey -And $null -NE $ADActivationObjectName -And $VLActivationType -EQ 1) {
+	if ($strSLP -EQ $wslp -And $NT8 -And $VLActivationType -EQ 1) {
 		DetectAdbaClient
 	}
 
-	if ($winID -And $null -NE $cAvmClient -And $null -NE $PartialProductKey) {
+	if ($winID -And $null -NE $cAvmClient) {
 		DetectAvmClient
 	}
 
 	$chkSub = ($winPR -And $cSub)
 
-	$chkSLS = ($null -NE $PartialProductKey) -And ($null -NE $cKmsClient -Or $null -NE $cKmsHost -Or $chkSub)
+	$chkSLS = ($null -NE $cKmsClient -Or $null -NE $cKmsServer -Or $chkSub)
 
 	if (!$chkSLS) {
 		if ($null -NE $ExpireMsg) {CONOUT "`n    $ExpireMsg"}
 		return
 	}
 
-	try
-	{
-		$objSvc = New-Object PSObject
-		$wmiSvc = [wmisearcher]"SELECT * FROM $strSLS"
-		$wmiSvc.Options.Rewindable = $false
-		$wmiSvc.Get() | select -Expand Properties -EA 0 | foreach { if (-Not [String]::IsNullOrEmpty($_.Value)) {$objSvc | Add-Member 8 $_.Name $_.Value} }
-		$wmiSvc.Dispose()
-		if ($null -EQ $IsKeyManagementServiceMachine) {$objSvc.PSObject.Properties | foreach {set $_.Name $_.Value}}
-	}
-	catch
-	{
-		return
-	}
-
-	if ($strSLS -EQ $wsls -And $NT9) {
-		if ([String]::IsNullOrEmpty($DiscoveredKeyManagementServiceMachineIpAddress)) {
-			$DiscoveredKeyManagementServiceMachineIpAddress = "not available"
-		}
-	}
-
-	if ($null -NE $cKmsHost -And $IsKeyManagementServiceMachine -GT 0) {
-		if ($null -NE $ExpireMsg) {CONOUT "`n    $ExpireMsg"}
+	if ($null -NE $cKmsServer) {
 		DetectKmsHost
 	}
 
@@ -590,7 +950,7 @@ function GetResult($strSLP, $strSLS, $strID)
 		DetectKmsClient
 	}
 
-	if ($null -EQ $cKmsHost) {
+	if ($null -EQ $cKmsServer) {
 		if ($null -NE $ExpireMsg) {CONOUT "`n    $ExpireMsg"}
 	}
 
@@ -599,6 +959,16 @@ function GetResult($strSLP, $strSLS, $strID)
 	}
 
 }
+
+function ParseList($strSLP, $strApp, $arrList)
+{
+	foreach ($entry in $arrList)
+	{
+		GetResult $strSLP $strApp $entry
+		CONOUT "$line3"
+		& $noAll
+	}
+}
 #endregion
 
 #region vNextDiag
@@ -817,31 +1187,6 @@ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #>
 
-function BoolToWStr($bVal) {
-	("TRUE", "FALSE")[!$bVal]
-}
-
-function InitializePInvoke {
-	$Marshal = [System.Runtime.InteropServices.Marshal]
-	$Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly((Get-Random), 'Run').DefineDynamicModule((Get-Random))
-
-	$Class = $Module.DefineType('NativeMethods', 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0)
-	$Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig')
-	$Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128)
-	$Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
-
-	if ($DllSubscription) {
-		$Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
-		$Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0)
-		[void]$Struct.DefineField('dwEnabled', [UInt32], 'Public')
-		[void]$Struct.DefineField('dwSku', [UInt32], 6)
-		[void]$Struct.DefineField('dwState', [UInt32], 6)
-		$SubStatus = $Struct.CreateType()
-	}
-
-	$Win32 = $Class.CreateType()
-}
-
 function InitializeDigitalLicenseCheck {
 	$CAB = [System.Reflection.Emit.CustomAttributeBuilder]
 
@@ -896,36 +1241,29 @@ function PrintLastActivationHResult {
 }
 
 function PrintLastActivationTime {
-	$pdwLastTime = 0
+	$pqwLastTime = 0
 	$cbSize = 0
 
 	if ($Win32::SLGetWindowsInformation(
 		"Security-SPP-LastWindowsActivationTime",
 		[ref]$null,
 		[ref]$cbSize,
-		[ref]$pdwLastTime
+		[ref]$pqwLastTime
 	)) {
 		return $FALSE
 	}
 
-	$actTime = $Marshal::ReadInt64($pdwLastTime)
+	$actTime = $Marshal::ReadInt64($pqwLastTime)
 	if ($actTime -ne 0) {
 		CONOUT ("    LastActivationTime={0}" -f [DateTime]::FromFileTimeUtc($actTime).ToString("yyyy/MM/dd:HH:mm:ss"))
 	}
 
-	$Marshal::FreeHGlobal($pdwLastTime)
+	$Marshal::FreeHGlobal($pqwLastTime)
 	return $TRUE
 }
 
 function PrintIsWindowsGenuine {
 	$dwGenuine = 0
-	$ppwszGenuineStates = @(
-		"SL_GEN_STATE_IS_GENUINE",
-		"SL_GEN_STATE_INVALID_LICENSE",
-		"SL_GEN_STATE_TAMPERED",
-		"SL_GEN_STATE_OFFLINE",
-		"SL_GEN_STATE_LAST"
-	)
 
 	if ($Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)) {
 		return $FALSE
@@ -1022,6 +1360,126 @@ function ClicRun
 }
 #endregion
 
+#region clc
+function clcGetExpireKrn
+{
+	$tData = 0
+	$cData = 0
+	$bData = 0
+
+	$ret = $Win32::SLGetWindowsInformation(
+		"Kernel-ExpirationDate",
+		[ref]$tData,
+		[ref]$cData,
+		[ref]$bData
+	)
+
+	if ($ret -Or !$cData -Or $tData -NE 3)
+	{
+		return $null
+	}
+
+	$year = $Marshal::ReadInt16($bData, 0)
+	if ($year -EQ 0 -Or $year -EQ 1601)
+	{
+		$rData = $null
+	}
+	else
+	{
+		$rData = '{0}/{1}/{2}:{3}:{4}:{5}' -f $year, $Marshal::ReadInt16($bData, 2), $Marshal::ReadInt16($bData, 4), $Marshal::ReadInt16($bData, 6), $Marshal::ReadInt16($bData, 8), $Marshal::ReadInt16($bData, 10)
+	}
+
+	$Marshal::FreeHGlobal($bData)
+	return $rData
+}
+
+function clcGetExpireSys
+{
+	$kuser = $Marshal::ReadInt64((New-Object IntPtr(0x7FFE02C8)))
+
+	if ($kuser -EQ 0)
+	{
+		return $null
+	}
+
+	$rData = [DateTime]::FromFileTimeUTC($kuser).ToString('yyyy/MM/dd:HH:mm:ss')
+	return $rData
+}
+
+function clcGetLicensingState($dwState)
+{
+	if ($dwState -EQ 5) {
+		$dwState = 3
+	} elseif ($dwState -EQ 3 -Or $dwState -EQ 4 -Or $dwState -EQ 6) {
+		$dwState = 2
+	} elseif ($dwState -GT 6) {
+		$dwState = 4
+	}
+
+	$rData = '{0}' -f $ppwszLicensingStates[$dwState]
+	return $rData
+}
+
+function clcGetGenuineState($AppId)
+{
+	$dwGenuine = 0
+
+	if ($NT7) {
+		$ret = $Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)
+	} else {
+		$ret = $Win32::SLIsGenuineLocal([ref][Guid]$AppId, [ref]$dwGenuine, 0)
+	}
+
+	if ($ret)
+	{
+		$dwGenuine = 4
+	}
+
+	if ($dwGenuine -LT 5) {
+		$rData = '{0}' -f $ppwszGenuineStates[$dwGenuine]
+	} else {
+		$rData = $dwGenuine
+	}
+	return $rData
+}
+
+function ClcRun
+{
+	$prs = $script:primary[0]
+	if ($null -EQ $prs) {
+		return
+	}
+
+	$lState = clcGetLicensingState $prs.lst
+	$uState = clcGetGenuineState $winApp
+	$TbbKrn = clcGetExpireKrn
+	$TbbSys = clcGetExpireSys
+	if ($null -NE $TbbKrn) {
+		$ked = $TbbKrn
+	} elseif ($null -NE $TbbSys) {
+		$ked = $TbbSys
+	}
+
+	& $isAll
+	CONOUT "Client Licensing Check information:"
+
+	CONOUT ("    AppId={0}" -f $winApp)
+	if ($prs.ged) { CONOUT ("    GraceEndDate={0}" -f ([DateTime]::UtcNow.AddMinutes($prs.ged).ToString('yyyy/MM/dd:HH:mm:ss'))) }
+	if ($null -NE $ked) { CONOUT ("    KernelTimebombDate={0}" -f $ked) }
+	CONOUT ("    LastConsumptionReason=0x{0:x8}" -f $prs.lcr)
+	if ($prs.evl) { CONOUT ("    LicenseExpirationDate={0}" -f ([DateTime]::FromFileTimeUtc($prs.evl).ToString('yyyy/MM/dd:HH:mm:ss'))) }
+	CONOUT ("    LicenseState={0}" -f $lState)
+	CONOUT ("    PartialProductKey={0}" -f $prs.ppk)
+	CONOUT ("    ProductKeyType={0}" -f $prs.chn)
+	CONOUT ("    SkuId={0}" -f $prs.aid)
+	CONOUT ("    uxDifferentiator={0}" -f $prs.dff)
+	CONOUT ("    IsWindowsGenuine={0}" -f $uState)
+
+	CONOUT "$line3"
+	& $noAll
+}
+#endregion
+
 $Host.UI.RawUI.WindowTitle = "Check Activation Status"
 if ($All.IsPresent) {
 	$B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B;
@@ -1040,14 +1498,38 @@ $osls = "OfficeSoftwareProtectionService"
 $winApp = "55c92734-d682-4d71-983e-d6ec3f16059f"
 $o14App = "59a52881-a989-479d-af46-f275c6370663"
 $o15App = "0ff1ce15-a989-479d-af46-f275c6370663"
-$cSub = ($winbuild -GE 19041) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType")
+$cSub = ($winbuild -GE 26000) -And (Select-String -Path "$SysPath\wbem\sppwmi.mof" -Encoding unicode -Pattern "SubscriptionType")
 $DllDigital = ($winbuild -GE 14393) -And (Test-Path "$SysPath\EditionUpgradeManagerObj.dll")
 $DllSubscription = ($winbuild -GE 14393) -And (Test-Path "$SysPath\Clipc.dll")
 $VLActTypes = @("All", "AD", "KMS", "Token")
+$OPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform"
+$SPKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
 $SLKeyPath = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
 $NSKeyPath = "HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
+$propPrd = 'Name', 'Description', 'TrustedTime', 'VLActivationType'
+$propPkey = 'PartialProductKey', 'Channel', 'DigitalPID', 'DigitalPID2'
+$propKMSServer = 'KeyManagementServiceCurrentCount', 'KeyManagementServiceTotalRequests', 'KeyManagementServiceFailedRequests', 'KeyManagementServiceUnlicensedRequests', 'KeyManagementServiceLicensedRequests', 'KeyManagementServiceOOBGraceRequests', 'KeyManagementServiceOOTGraceRequests', 'KeyManagementServiceNonGenuineGraceRequests', 'KeyManagementServiceNotificationRequests'
+$propKMSClient = 'CustomerPID', 'KeyManagementServiceName', 'KeyManagementServicePort', 'DiscoveredKeyManagementServiceName', 'DiscoveredKeyManagementServicePort', 'DiscoveredKeyManagementServiceIpAddress', 'VLActivationInterval', 'VLRenewalInterval', 'KeyManagementServiceLookupDomain'
+$propKMSVista  = 'CustomerPID', 'KeyManagementServiceName', 'VLActivationInterval', 'VLRenewalInterval'
+$propADBA = 'ADActivationObjectName', 'ADActivationObjectDN', 'ADActivationCsvlkPID', 'ADActivationCsvlkSkuID'
+$propAVMA = 'InheritedActivationId', 'InheritedActivationHostMachineName', 'InheritedActivationHostDigitalPid2', 'InheritedActivationActivationTime'
+$primary = @()
+$ppwszGenuineStates = @(
+	"SL_GEN_STATE_IS_GENUINE",
+	"SL_GEN_STATE_INVALID_LICENSE",
+	"SL_GEN_STATE_TAMPERED",
+	"SL_GEN_STATE_OFFLINE",
+	"SL_GEN_STATE_LAST"
+)
+$ppwszLicensingStates = @(
+	"SL_LICENSING_STATUS_UNLICENSED",
+	"SL_LICENSING_STATUS_LICENSED",
+	"SL_LICENSING_STATUS_IN_GRACE_PERIOD",
+	"SL_LICENSING_STATUS_NOTIFICATION",
+	"SL_LICENSING_STATUS_LAST"
+)
 
-'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ $false}
+'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ @()}
 
 $offsvc = "osppsvc"
 if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"}
@@ -1055,83 +1537,102 @@ if ($NT7 -Or -Not $NT6) {$winsvc = "sppsvc"} else {$winsvc = "slsvc"}
 try {gsv $winsvc -EA 1 | Out-Null; $WsppHook = 1} catch {$WsppHook = 0}
 try {gsv $offsvc -EA 1 | Out-Null; $OsppHook = 1} catch {$OsppHook = 0}
 
-if ($WsppHook -NE 0) {
-	try {sasv $winsvc -EA 1} catch {}
-	$cW1nd0ws  = DetectID $wslp $winApp
-	$c0ff1ce15 = DetectID $wslp $o15App
-	$c0ff1ce14 = DetectID $wslp $o14App
+if (Test-Path "$SysPath\sppc.dll") {
+	$SLdll = 'sppc.dll'
+} elseif (Test-Path "$SysPath\slc.dll") {
+	$SLdll = 'slc.dll'
+} else {
+	$WsppHook = 0
 }
 
 if ($OsppHook -NE 0) {
-	try {sasv $offsvc -EA 1} catch {}
-	$ospp15 = DetectID $oslp $o15App
-	$ospp14 = DetectID $oslp $o14App
+	$OLdll = (strGetRegistry $OPKeyPath "Path") + 'osppc.dll'
+	if (!(Test-Path "$OLdll")) {$OsppHook = 0}
 }
 
-if ($cW1nd0ws)
+if ($WsppHook -NE 0) {
+	if ($NT6 -And -Not $NT7 -And -Not $Admin) {
+		if ($null -EQ [Diagnostics.Process]::GetProcessesByName("$winsvc")[0].ProcessName) {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"}
+	} else {
+		try {sasv $winsvc -EA 1} catch {$WsppHook = 0; CONOUT "`nError: failed to start $winsvc Service.`n"}
+	}
+}
+
+if ($WsppHook -NE 0) {
+	. InitializePInvoke $SLdll $false
+	$hSLC = 0
+	[void]$Win32::SLOpen([ref]$hSLC)
+
+	$cW1nd0ws  = SlGetInfoSLID $winApp
+	$c0ff1ce15 = SlGetInfoSLID $o15App
+	$c0ff1ce14 = SlGetInfoSLID $o14App
+}
+
+if ($cW1nd0ws.Count -GT 0)
 {
 	echoWindows
-	GetID $wslp $winApp | foreach -EA 1 {
-	GetResult $wslp $wsls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+	ParseList $wslp $winApp $cW1nd0ws
 }
 elseif ($NT6)
 {
 	echoWindows
-	CONOUT "`nError: product key not found."
+	CONOUT "Error: product key not found.`n"
 }
 
-if ($winbuild -GE 9200) {
-	. InitializePInvoke
+if ($NT6 -And -Not $NT8) {
+	ClcRun
+}
+
+if ($NT8) {
 	ClicRun
 }
 
-if ($c0ff1ce15 -Or $ospp15) {
-	CheckOhook
-}
-
 $doMSG = 1
 
-if ($c0ff1ce15)
+if ($c0ff1ce15.Count -GT 0)
 {
+	CheckOhook
 	echoOffice
-	GetID $wslp $o15App | foreach -EA 1 {
-	GetResult $wslp $wsls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+	ParseList $wslp $o15App $c0ff1ce15
 }
 
-if ($c0ff1ce14)
+if ($c0ff1ce14.Count -GT 0)
 {
 	echoOffice
-	GetID $wslp $o14App | foreach -EA 1 {
-	GetResult $wslp $wsls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+	ParseList $wslp $o14App $c0ff1ce14
 }
 
-if ($ospp15)
-{
-	echoOffice
-	GetID $oslp $o15App | foreach -EA 1 {
-	GetResult $oslp $osls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+if ($hSLC) {
+	[void]$Win32::SLClose($hSLC)
 }
 
-if ($ospp14)
+if ($OsppHook -NE 0) {
+	try {sasv $offsvc -EA 1} catch {$OsppHook = 0; CONOUT "`nError: failed to start $offsvc Service.`n"}
+}
+
+if ($OsppHook -NE 0) {
+	. InitializePInvoke "$OLdll" $true
+	$hSLC = 0
+	[void]$Win32::SLOpen([ref]$hSLC)
+
+	$ospp15 = SlGetInfoSLID $o15App
+	$ospp14 = SlGetInfoSLID $o14App
+}
+
+if ($ospp15.Count -GT 0)
 {
 	echoOffice
-	GetID $oslp $o14App | foreach -EA 1 {
-	GetResult $oslp $osls $_
-	CONOUT "$line3"
-	& $noAll
-	}
+	ParseList $oslp $o15App $ospp15
+}
+
+if ($ospp14.Count -GT 0)
+{
+	echoOffice
+	ParseList $oslp $o14App $ospp14
+}
+
+if ($hSLC) {
+	[void]$Win32::SLClose($hSLC)
 }
 
 if ($NT7) {