@ -6509,20 +6509,40 @@ mode 100, 36
@@ -6509,20 +6509,40 @@ mode 100, 36
goto dk_done
: sppmgr :
param (
[Parameter()]
[switch]
$All,
[Parameter()]
[switch]
$Dlv,
[Parameter()]
[switch]
$IID,
[Parameter()]
[switch]
$Pass
)
function CONOUT($strObj)
{
Out-Host -Input $strObj
}
function ExitScript($ExitCode = 0)
{
Exit $ExitCode
}
if (-Not $ P S V e r s i o n T a b l e ) {
Write-Host " ==== ERROR ====`r`n "
Write-Host 'Windows PowerShell 1.0 is not supported by this script.'
" ==== ERROR ====`r`n "
" Windows PowerShell 1.0 is not supported by this script. "
ExitScript 1
}
if ($ExecutionContext.SessionState.LanguageMode.value__ - N E 0 ) {
Write-Host " ==== ERROR ====`r`n "
Write-Host 'Windows PowerShell is not running in Full Language Mode.'
" ==== ERROR ====`r`n "
" Windows PowerShell is not running in Full Language Mode. "
ExitScript 1
}
@ -6530,21 +6550,49 @@ $winbuild = 1
@@ -6530,21 +6550,49 @@ $winbuild = 1
try {
$winbuild = [System.Diagnostics.FileVersionInfo]::GetVersionInfo(" $env:SystemRoot\System32\kernel32.dll " ).FileBuildPart
} catch {
$winbuild = [int](Get-WmiObject Win32_OperatingSystem ).BuildNumber
$winbuild = [int]([wmi]'Win32_OperatingSystem=@' ).BuildNumber
}
if ($winbuild - E Q 1 ) {
Write-Host " ==== ERROR ====`r`n "
Write-Host 'Could not detect Windows build.'
" ==== ERROR ====`r`n "
" Could not detect Windows build. "
ExitScript 1
}
if ($winbuild - L T 2 6 0 0 ) {
Write-Host " ==== ERROR ====`r`n "
Write-Host 'This build of Windows is not supported by this script.'
" ==== ERROR ====`r`n "
" This build of Windows is not supported by this script. "
ExitScript 1
}
$SysPath = " $env:SystemRoot\System32 "
if (Test-Path " $ e n v : S y s t e m R o o t \ S y s n a t i v e \ r e g . e x e " ) {
$SysPath = " $env:SystemRoot\Sysnative "
}
if (Test-Path " $ S y s P a t h \ s p p c . d l l " ) {
$SLdll = 'sppc.dll'
} elseif (Test-Path " $SysPath\slc.dll " ) {
$SLdll = 'slc.dll'
} else {
" ==== ERROR ====`r`n "
" Software Licensing Client Dll is not detected. "
ExitScript 1
}
if ($All.IsPresent)
{
$isAll = {CONOUT " `r " }
$noAll = {$null}
}
else
{
$isAll = {$null}
$noAll = {CONOUT " `r " }
}
$Dlv = $Dlv.IsPresent
$IID = $IID.IsPresent -Or $Dlv.IsPresent
$NT6 = $winbuild -GE 6000
$NT7 = $winbuild -GE 7600
$NT9 = $winbuild -GE 9600
@ -6554,12 +6602,29 @@ $Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
@@ -6554,12 +6602,29 @@ $Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
$line2 = " ============================================================ "
$line3 = " ____________________________________________________________ "
function UnQuickEdit
{
$t=[AppDomain]::CurrentDomain.DefineDynamicAssembly((Get-Random), 1).DefineDynamicModule((Get-Random), $False).DefineType((Get-Random))
$t.DefinePInvokeMethod('GetStdHandle', 'kernel32.dll', 22, 1, [IntPtr], @([Int32]), 1, 3).SetImplementationFlags(128)
$t.DefinePInvokeMethod('SetConsoleMode', 'kernel32.dll', 22, 1, [Boolean], @([IntPtr], [Int32]), 1, 3).SetImplementationFlags(128)
$t.DefinePInvokeMethod('GetConsoleWindow', 'kernel32.dll', 22, 1, [IntPtr], @(), 1, 3).SetImplementationFlags(128)
$t.DefinePInvokeMethod('SendMessageW', 'user32.dll', 22, 1, [IntPtr], @([IntPtr], [UInt32], [IntPtr], [IntPtr]), 1, 3).SetImplementationFlags(128)
$k=$t.CreateType()
if ($winbuild - G E 1 7 7 6 3 ) {
if ($k::SendMessageW($k::GetConsoleWindow(), 1 2 7 , 0 , 0 ) - E Q [ I n t P t r ] : : Z e r o ) {
return
}
}
$v=(0x0080, 0x00A0)[!($winbuild -GE 10586)]
$b=$k::SetConsoleMode($k::GetStdHandle(-10), $v)
}
function echoWindows
{
Write-Host " $line2 "
Write-Host " === Windows Status === "
Write-Host " $line2 "
if (!$All.IsPresent) { W r i t e - H o s t }
CONOUT " $line2 "
CONOUT " === Windows Status === "
CONOUT " $line2 "
& $noAll
}
function echoOffice
@ -6568,18 +6633,22 @@ function echoOffice
@@ -6568,18 +6633,22 @@ function echoOffice
return
}
if ($All.IsPresent) { W r i t e - H o s t }
Write-Host " $line2 "
Write-Host " === Office Status === "
Write-Host " $line2 "
if (!$All.IsPresent) { W r i t e - H o s t }
& $isAll
CONOUT " $line2 "
CONOUT " === Office Status === "
CONOUT " $line2 "
& $noAll
$script:doMSG = 0
}
function strGetRegistry($strKey, $strName)
{
Get-ItemProperty -EA 0 $strKey | select -EA 0 -Expand $strName
try {
return [Microsoft.Win32.Registry]::GetValue($strKey, $strName, $null)
} catch {
return $null
}
}
function CheckOhook
@ -6610,55 +6679,57 @@ function CheckOhook
@@ -6610,55 +6679,57 @@ function CheckOhook
return
}
if ($All.IsPresent) { W r i t e - H o s t }
Write-Host " $line2 "
Write-Host " === Office Ohook Status === "
Write-Host " $line2 "
Write-Host
Write-Host -back 'Black' -fore 'Yellow' 'Ohook for permanent Office activation is installed.'
Write-Host -back 'Black' -fore 'Yellow' 'You can ignore the below mentioned Office activation status.'
if (!$All.IsPresent) { W r i t e - H o s t }
& $isAll
CONOUT " $line2 "
CONOUT " === Office Ohook Status === "
CONOUT " $line2 "
$host.UI.WriteLine('Yellow', 'Black', " `r`nOhook for permanent Office activation is installed.`r`nYou can ignore the below mentioned Office activation status. " )
& $noAll
}
#region WMI
function DetectID($strSLP, $strAppId, [ref]$strAppVar )
function DetectID($strSLP, $strAppId)
{
$fltr = " ApplicationID='$strAppId' "
if (!$All.IsPresent) {
$fltr = $fltr + " AND PartialProductKey <> NULL "
}
Get-WmiObject $strSLP ID -Filter $fltr -EA 0 | select ID -EA 0 | foreach {
$strAppVar.Value = 1
}
$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)
}
function GetID($strSLP, $strAppId, $strProperty = " ID " )
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 "
if ($All.IsPresent) {
$fltr = " ApplicationID='$strAppId' AND PartialProductKey IS NULL "
$clause = $fltr
if (-Not $ N T 5 ) {
$clause = $fltr + " AND LicenseDependsOn <> NULL "
}
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
$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 $ N T 5 ) {
$clause = $fltr + " AND LicenseDependsOn IS NULL "
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
$clause = $fltr + $noAdd
$sWmi = [wmisearcher]$clause
$sWmi.Options.Rewindable = $false
try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
}
}
$fltr = " ApplicationID='$strAppId' AND PartialProductKey <> NULL "
$clause = $fltr
if (-Not $ N T 5 ) {
$clause = $fltr + " AND LicenseDependsOn <> NULL "
}
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
$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 $ N T 5 ) {
$clause = $fltr + " AND LicenseDependsOn IS NULL "
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
$clause = $fltr + $noAdd
$sWmi = [wmisearcher]$clause
$sWmi.Options.Rewindable = $false
try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
}
return $IDs
@ -6695,38 +6766,45 @@ function DetectSubscription {
@@ -6695,38 +6766,45 @@ function DetectSubscription {
if ($objSvc.SubscriptionEdition.Contains(" UNKNOWN " ) - E Q $ f a l s e ) { $ S u b M s g E d i t i o n = $ o b j S v c . S u b s c r i p t i o n E d i t i o n }
}
Write-Host
Write-Host " Subscription information: "
Write-Host " Edition: $SubMsgEdition "
Write-Host " Type : $SubMsgType "
Write-Host " Status : $SubMsgStatus "
Write-Host " Expiry : $SubMsgExpiry "
CONOUT " `nSubscription information: "
CONOUT " Edition: $SubMsgEdition "
CONOUT " Type : $SubMsgType "
CONOUT " Status : $SubMsgStatus "
CONOUT " Expiry : $SubMsgExpiry "
}
function DetectAdbaClient
{
CONOUT " `nAD Activation client information: "
CONOUT " Object Name: $ADActivationObjectName "
CONOUT " Domain Name: $ADActivationObjectDN "
CONOUT " CSVLK Extended PID: $ADActivationCsvlkPid "
CONOUT " CSVLK Activation ID: $ADActivationCsvlkSkuId "
}
function DetectAvmClient
{
Write-Host
Write-Host " Automatic VM Activation client information: "
CONOUT " `nAutomatic VM Activation client information: "
if (-Not [ S t r i n g ] : : I s N u l l O r E m p t y ( $ I A I D ) ) {
Write-Host " Guest IAID: $IAID "
CONOUT " Guest IAID: $IAID "
} else {
Write-Host " Guest IAID: Not Available "
CONOUT " Guest IAID: Not Available "
}
if (-Not [ S t r i n g ] : : I s N u l l O r E m p t y ( $ A u t o m a t i c V M A c t i v a t i o n H o s t M a c h i n e N a m e ) ) {
Write-Host " Host machine name: $AutomaticVMActivationHostMachineName "
CONOUT " Host machine name: $AutomaticVMActivationHostMachineName "
} else {
Write-Host " Host machine name: Not Available "
CONOUT " Host machine name: Not Available "
}
if ($AutomaticVMActivationLastActivationTime.Substring(0, 4 ) - N E " 1 6 0 1 " ) {
$EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($AutomaticVMActivationLastActivationTime),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt')
Write-Host " Activation time: $EED UTC "
CONOUT " Activation time: $EED UTC "
} else {
Write-Host " Activation time: Not Available "
CONOUT " Activation time: Not Available "
}
if (-Not [ S t r i n g ] : : I s N u l l O r E m p t y ( $ A u t o m a t i c V M A c t i v a t i o n H o s t D i g i t a l P i d 2 ) ) {
Write-Host " Host Digital PID2: $AutomaticVMActivationHostDigitalPid2 "
CONOUT " Host Digital PID2: $AutomaticVMActivationHostDigitalPid2 "
} else {
Write-Host " Host Digital PID2: Not Available "
CONOUT " Host Digital PID2: Not Available "
}
}
@ -6756,32 +6834,30 @@ function DetectKmsHost
@@ -6756,32 +6834,30 @@ function DetectKmsHost
$KeyManagementServiceLowPriority = " Normal "
}
Write-Host
Write-Host " Key Management Service host information: "
Write-Host " Current count: $KeyManagementServiceCurrentCount "
Write-Host " Listening on Port: $KeyManagementServiceListeningPort "
Write-Host " DNS publishing: $KeyManagementServiceDnsPublishing "
Write-Host " KMS priority: $KeyManagementServiceLowPriority "
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 [ S t r i n g ] : : I s N u l l O r E m p t y ( $ K e y M a n a g e m e n t S e r v i c e T o t a l R e q u e s t s ) ) {
Write-Host
Write-Host " Key Management Service cumulative requests received from clients: "
Write-Host " Total: $KeyManagementServiceTotalRequests "
Write-Host " Failed: $KeyManagementServiceFailedRequests "
Write-Host " Unlicensed: $KeyManagementServiceUnlicensedRequests "
Write-Host " Licensed: $KeyManagementServiceLicensedRequests "
Write-Host " Initial grace period: $KeyManagementServiceOOBGraceRequests "
Write-Host " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests "
Write-Host " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests "
Write-Host " Notification: $KeyManagementServiceNotificationRequests "
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 - N E $ K e y M a n a g e m e n t S e r v i c e N o t i f i c a t i o n R e q u e s t s ) { C O N O U T " N o t i f i c a t i o n : $ K e y M a n a g e m e n t S e r v i c e N o t i f i c a t i o n R e q u e s t s " }
}
}
function DetectKmsClient
{
if ($null - N E $ V L A c t i v a t i o n T y p e E n a b l e d ) { W r i t e - H o s t " C o n f i g u r e d A c t i v a t i o n T y p e : $ ( $ V L A c t T y p e s [ $ V L A c t i v a t i o n T y p e E n a b l e d ] ) " }
Write-Host
if ($null - N E $ V L A c t i v a t i o n T y p e E n a b l e d ) { C O N O U T " C o n f i g u r e d A c t i v a t i o n T y p e : $ ( $ V L A c t T y p e s [ $ V L A c t i v a t i o n T y p e E n a b l e d ] ) " }
CONOUT " `r "
if ($LicenseStatus - N E 1 ) {
Write-Host " Please activate the product in order to update KMS client information values. "
CONOUT " Please activate the product in order to update KMS client information values. "
return
}
@ -6814,33 +6890,42 @@ function DetectKmsClient
@@ -6814,33 +6890,42 @@ function DetectKmsClient
}
}
Write-Host " Key Management Service client information: "
Write-Host " Client Machine ID (CMID): $($objSvc.ClientMachineID) "
CONOUT " Key Management Service client information: "
CONOUT " Client Machine ID (CMID): $($objSvc.ClientMachineID) "
if ($null - E Q $ K m s R e g ) {
Write-Host " $KmsDns "
Write-Host " Registered KMS machine name: KMS name not available "
CONOUT " $KmsDns "
CONOUT " Registered KMS machine name: KMS name not available "
} else {
Write-Host " $KmsReg "
CONOUT " $KmsReg "
}
if ($null - N E $ D i s c o v e r e d K e y M a n a g e m e n t S e r v i c e M a c h i n e I p A d d r e s s ) { W r i t e - H o s t " K M S m a c h i n e I P a d d r e s s : $ D i s c o v e r e d K e y M a n a g e m e n t S e r v i c e M a c h i n e I p A d d r e s s " }
Write-Host " KMS machine extended PID: $KeyManagementServiceProductKeyID "
Write-Host " Activation interval: $VLActivationInterval minutes "
Write-Host " Renewal interval: $VLRenewalInterval minutes "
if ($null - N E $ K e y M a n a g e m e n t S e r v i c e H o s t C a c h i n g ) { W r i t e - H o s t " K M S h o s t c a c h i n g : $ K e y M a n a g e m e n t S e r v i c e H o s t C a c h i n g " }
if (-Not [ S t r i n g ] : : I s N u l l O r E m p t y ( $ K e y M a n a g e m e n t S e r v i c e L o o k u p D o m a i n ) ) { W r i t e - H o s t " K M S S R V r e c o r d l o o k u p d o m a i n : $ K e y M a n a g e m e n t S e r v i c e L o o k u p D o m a i n " }
if ($null - N E $ D i s c o v e r e d K e y M a n a g e m e n t S e r v i c e M a c h i n e I p A d d r e s s ) { C O N O U T " K M S m a c h i n e I P a d d r e s s : $ D i s c o v e r e d K e y M a n a g e m e n t S e r v i c e M a c h i n e I p A d d r e s s " }
CONOUT " KMS machine extended PID: $KeyManagementServiceProductKeyID "
CONOUT " Activation interval: $VLActivationInterval minutes "
CONOUT " Renewal interval: $VLRenewalInterval minutes "
if ($null - N E $ K e y M a n a g e m e n t S e r v i c e H o s t C a c h i n g ) { C O N O U T " K M S h o s t c a c h i n g : $ K e y M a n a g e m e n t S e r v i c e H o s t C a c h i n g " }
if (-Not [ S t r i n g ] : : I s N u l l O r E m p t y ( $ K e y M a n a g e m e n t S e r v i c e L o o k u p D o m a i n ) ) { C O N O U T " K M S S R V r e c o r d l o o k u p d o m a i n : $ K e y M a n a g e m e n t S e r v i c e L o o k u p D o m a i n " }
}
function GetResult($strSLP, $strSLS, $strID)
{
try {$objPrd = Get-WmiObject $strSLP -Filter " ID='$strID' " -EA 1} catch {return}
$objPrd | select -Expand Properties -EA 0 | foreach {
if (-Not [ S t r i n g ] : : I s N u l l O r E m p t y ( $ _ . V a l u e ) ) { s e t $ _ . N a m e $ _ . V a l u e }
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
}
$winID = ($ApplicationID -EQ $winApp)
$winPR = ($winID -And -Not $LicenseIsAddon)
$Vista = ($winID -And $NT6 -And -Not $NT7)
$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
$reapp = (" Windows " , " App " )[!$winID]
$prmnt = (" machine " , " product " )[!$winPR]
if ($Description | S e l e c t - S t r i n g " V O L U M E _ K M S C L I E N T " ) { $ c K m s C l i e n t = 1 ; $ _ m T a g = " V o l u m e " }
if ($Description | S e l e c t - S t r i n g " T I M E B A S E D _ " ) { $ c T b l C l i e n t = 1 ; $ _ m T a g = " T i m e b a s e d " }
@ -6865,7 +6950,7 @@ function GetResult($strSLP, $strSLS, $strID)
@@ -6865,7 +6950,7 @@ function GetResult($strSLP, $strSLS, $strID)
$LicenseInf = " Licensed "
$LicenseMsg = $null
if ($GracePeriodRemaining - E Q 0 ) {
if ($winPR) { $ E x p i r e M s g = " T h e m a c h i n e i s p e r m a n e n t l y a c t i v a t e d . " } e l s e { $ E x p i r e M s g = " T h e p r o d u c t i s p e r m a n e n t l y a c t i v a t e d . " }
$ExpireMsg = " The $prmnt is permanently activated. "
} else {
$LicenseMsg = " $_mTag activation expiration: $GracePeriodRemaining minute(s) ($_gpr day(s)) "
if ($null - N E $ _ x p r ) { $ E x p i r e M s g = " $ _ m T a g a c t i v a t i o n w i l l e x p i r e $ _ x p r " }
@ -6886,8 +6971,9 @@ function GetResult($strSLP, $strSLS, $strID)
@@ -6886,8 +6971,9 @@ function GetResult($strSLP, $strSLS, $strID)
if ($LicenseStatus - E Q 5 - A n d - N o t $ N T 5 ) {
$LicenseInf = " Notification "
$LicenseMsg = " Notification Reason: $LicenseReason "
if ($LicenseReason - E Q " 0 x C 0 0 4 F 0 0 F " ) { i f ( $ n u l l - N E $ c K m s C l i e n t ) { $ L i c e n s e M s g = $ L i c e n s e M s g + " ( K M S l i c e n s e e x p i r e d ) . " } e l s e { $ L i c e n s e M s g = $ L i c e n s e M s g + " ( h a r d w a r e o u t o f t o l e r a n c e ) . " } }
if ($LicenseReason - E Q " 0 x C 0 0 4 F 2 0 0 " ) { $ L i c e n s e M s g = $ L i c e n s e M s g + " ( n o n - g e n u i n e ) . " }
if ($LicenseReason - E Q " 0 x C 0 0 4 F 0 0 9 " ) { $ L i c e n s e M s g = $ L i c e n s e M s g + " ( g r a c e t i m e e x p i r e d ) . " }
if ($LicenseReason - E Q " 0 x C 0 0 4 F 0 0 9 " - O r $ L i c e n s e R e a s o n - E Q " 0 x C 0 0 4 F 0 6 4 " ) { $ L i c e n s e M s g = $ L i c e n s e M s g + " ( g r a c e t i m e e x p i r e d ) . " }
}
if ($LicenseStatus - G T 5 - O r ( $ L i c e n s e S t a t u s - G T 4 - A n d $ N T 5 ) ) {
$LicenseInf = " Unknown "
@ -6899,25 +6985,61 @@ function GetResult($strSLP, $strSLS, $strID)
@@ -6899,25 +6985,61 @@ function GetResult($strSLP, $strSLS, $strID)
}
if ($winPR - A n d $ P a r t i a l P r o d u c t K e y - A n d - N o t $ N T 9 ) {
$dp4 = Get-ItemProperty -EA 0 " HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion " | select -EA 0 -Expand DigitalProductId4
$dp4 = strGetRegistry " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion " " DigitalProductId4 "
if ($null - N E $ d p 4 ) {
$ProductKeyChannel = ([System.Text.Encoding]::Unicode.GetString($dp4, 1016, 128)).Trim([char]$null)
}
}
if ($All.IsPresent) { W r i t e - H o s t }
Write-Host " Name: $Name "
Write-Host " Description: $Description "
Write-Host " Activation ID: $ID "
if ($null - N E $ P r o d u c t K e y I D ) { W r i t e - H o s t " E x t e n d e d P I D : $ P r o d u c t K e y I D " }
if ($null - N E $ O f f l i n e I n s t a l l a t i o n I d - A n d $ I I D . I s P r e s e n t ) { W r i t e - H o s t " I n s t a l l a t i o n I D : $ O f f l i n e I n s t a l l a t i o n I d " }
if ($null - N E $ P r o d u c t K e y C h a n n e l ) { W r i t e - H o s t " P r o d u c t K e y C h a n n e l : $ P r o d u c t K e y C h a n n e l " }
if ($null - N E $ P a r t i a l P r o d u c t K e y ) { W r i t e - H o s t " P a r t i a l P r o d u c t K e y : $ P a r t i a l P r o d u c t K e y " } e l s e { W r i t e - H o s t " P r o d u c t K e y : N o t i n s t a l l e d " }
Write-Host " License Status: $LicenseInf "
if ($null - N E $ L i c e n s e M s g ) { W r i t e - H o s t " $ L i c e n s e M s g " }
if ($winPR - A n d $ D l v - A n d $ n u l l - E Q $ R e m a i n i n g A p p R e A r m C o u n t ) {
try
{
$tmp = [wmisearcher]" SELECT RemainingWindowsReArmCount FROM $strSLS "
$tmp.Options.Rewindable = $false
$tmp.Get() | select -Expand Properties -EA 0 | foreach {set $_.Name $_.Value}
$tmp.Dispose()
}
catch
{
}
}
$add_on = $Name.IndexOf(" add-on for " , 5)
& $isAll
if ($add_on - E Q - 1 ) { C O N O U T " N a m e : $ N a m e " } e l s e { C O N O U T " N a m e : $ ( $ N a m e . S u b s t r i n g ( 0 , $ a d d _ o n + 7 ) ) " }
CONOUT " Description: $Description "
CONOUT " Activation ID: $ID "
if ($null - N E $ P r o d u c t K e y I D ) { C O N O U T " E x t e n d e d P I D : $ P r o d u c t K e y I D " }
if ($null - N E $ P r o d u c t K e y I D 2 - A n d $ D l v ) { C O N O U T " P r o d u c t I D : $ P r o d u c t K e y I D 2 " }
if ($null - N E $ O f f l i n e I n s t a l l a t i o n I d - A n d $ I I D ) { C O N O U T " I n s t a l l a t i o n I D : $ O f f l i n e I n s t a l l a t i o n I d " }
if ($null - N E $ P r o d u c t K e y C h a n n e l ) { C O N O U T " P r o d u c t K e y C h a n n e l : $ P r o d u c t K e y C h a n n e l " }
if ($null - N E $ P a r t i a l P r o d u c t K e y ) { C O N O U T " P a r t i a l P r o d u c t K e y : $ P a r t i a l P r o d u c t K e y " }
CONOUT " License Status: $LicenseInf "
if ($null - N E $ L i c e n s e M s g ) { C O N O U T " $ L i c e n s e M s g " }
if ($LicenseStatus - N E 0 - A n d $ E v a l u a t i o n E n d D a t e . S u b s t r i n g ( 0 , 4 ) - N E " 1 6 0 1 " ) {
$EED = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($EvaluationEndDate),$null,48).ToString('yyyy-MM-dd hh:mm:ss tt')
Write-Host " Evaluation End Date: $EED UTC "
CONOUT " Evaluation End Date: $EED UTC "
}
if ($Dlv) {
if ($null - N E $ R e m a i n i n g W i n d o w s R e A r m C o u n t ) {
CONOUT " Remaining Windows rearm count: $RemainingWindowsReArmCount "
}
if ($null - N E $ R e m a i n i n g S k u R e A r m C o u n t - A n d $ R e m a i n i n g S k u R e A r m C o u n t - N E 4 2 9 4 9 6 7 2 9 5 ) {
CONOUT " Remaining $reapp rearm count: $RemainingAppReArmCount "
CONOUT " Remaining SKU rearm count: $RemainingSkuReArmCount "
}
if ($null - N E $ T r u s t e d T i m e - A n d $ L i c e n s e S t a t u s - N E 0 ) {
$TTD = [DateTime]::Parse([Management.ManagementDateTimeConverter]::ToDateTime($TrustedTime),$null,32).ToString('yyyy-MM-dd hh:mm:ss tt')
CONOUT " Trusted time: $TTD "
}
}
if ($LicenseStatus - E Q 0 ) {
return
}
if ($strSLP - E Q $ w s l p - A n d $ n u l l - N E $ P a r t i a l P r o d u c t K e y - A n d $ n u l l - N E $ A D A c t i v a t i o n O b j e c t N a m e - A n d $ V L A c t i v a t i o n T y p e - E Q 1 ) {
DetectAdbaClient
}
if ($winID - A n d $ n u l l - N E $ c A v m C l i e n t - A n d $ n u l l - N E $ P a r t i a l P r o d u c t K e y ) {
@ -6929,16 +7051,27 @@ function GetResult($strSLP, $strSLS, $strID)
@@ -6929,16 +7051,27 @@ function GetResult($strSLP, $strSLS, $strID)
$chkSLS = ($null -NE $PartialProductKey) -And ($null -NE $cKmsClient -Or $null -NE $cKmsHost -Or $chkSub)
if (!$chkSLS) {
if ($null - N E $ E x p i r e M s g ) { W r i t e - H o s t ; W r i t e - H o s t " $ E x p i r e M s g " }
if ($null - N E $ E x p i r e M s g ) { C O N O U T " ` n $ E x p i r e M s g " }
return
}
$objSvc = Get-WmiObject $strSLS -EA 0
if ($Vista) {
$objSvc | select -Expand Properties -EA 0 | foreach {
if (-Not [ S t r i n g ] : : I s N u l l O r E m p t y ( $ _ . V a l u e ) ) { s e t $ _ . N a m e $ _ . V a l u e }
try
{
$objSvc = New-Object PSObject
$wmiSvc = [wmisearcher]" SELECT * FROM $strSLS "
$wmiSvc.Options.Rewindable = $false
$wmiSvc.Get() | select -Expand Properties -EA 0 | foreach {
if (-Not [ S t r i n g ] : : I s N u l l O r E m p t y ( $ _ . V a l u e ) )
{
$objSvc | Add-Member 8 $_.Name $_.Value
if ($null - E Q $ I s K e y M a n a g e m e n t S e r v i c e M a c h i n e ) { s e t $ _ . N a m e $ _ . V a l u e }
}
}
$wmiSvc.Dispose()
}
catch
{
return
}
if ($strSLS - E Q $ w s l s - A n d $ N T 9 ) {
@ -6948,6 +7081,7 @@ function GetResult($strSLP, $strSLS, $strID)
@@ -6948,6 +7081,7 @@ function GetResult($strSLP, $strSLS, $strID)
}
if ($null - N E $ c K m s H o s t - A n d $ I s K e y M a n a g e m e n t S e r v i c e M a c h i n e - G T 0 ) {
if ($null - N E $ E x p i r e M s g ) { C O N O U T " ` n $ E x p i r e M s g " }
DetectKmsHost
}
@ -6955,7 +7089,9 @@ function GetResult($strSLP, $strSLS, $strID)
@@ -6955,7 +7089,9 @@ function GetResult($strSLP, $strSLS, $strID)
DetectKmsClient
}
if ($null - N E $ E x p i r e M s g ) { W r i t e - H o s t ; W r i t e - H o s t " $ E x p i r e M s g " }
if ($null - E Q $ c K m s H o s t ) {
if ($null - N E $ E x p i r e M s g ) { C O N O U T " ` n $ E x p i r e M s g " }
}
if ($chkSub) {
DetectSubscription
@ -6995,11 +7131,10 @@ function PrintModePerPridFromRegistry
@@ -6995,11 +7131,10 @@ function PrintModePerPridFromRegistry
$vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty 'property' -ErrorAction SilentlyContinue | Where-Object -FilterScript {$_.ToLower() -like " *retail " -or $_.ToLower() -like " *volume " }
If ($null - E q $ v N e x t P r i d s )
{
Write-Host
Write-Host " No registry keys found. "
CONOUT " `nNo registry keys found. "
Return
}
Write-Host
CONOUT " `r "
$vNextPrids | ForEach `
{
$mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_
@ -7009,7 +7144,7 @@ function PrintModePerPridFromRegistry
@@ -7009,7 +7144,7 @@ function PrintModePerPridFromRegistry
3 { $mode = " Device " ; Break }
Default { $mode = " Legacy " ; Break }
}
Write-Host $_ = $mode
CONOUT " $_ = $mode "
}
}
@ -7023,8 +7158,7 @@ function PrintSharedComputerLicensing
@@ -7023,8 +7158,7 @@ function PrintSharedComputerLicensing
$scaPolicyValue = Get-ItemProperty -Path $scaPolicyKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty " SharedComputerLicensing " -ErrorAction SilentlyContinue
If ($null - E q $ s c a V a l u e - A n d $ n u l l - E q $ s c a V a l u e 2 - A n d $ n u l l - E q $ s c a P o l i c y V a l u e )
{
Write-Host
Write-Host " No registry keys found. "
CONOUT " `nNo registry keys found. "
Return
}
$scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue
@ -7036,9 +7170,8 @@ function PrintSharedComputerLicensing
@@ -7036,9 +7170,8 @@ function PrintSharedComputerLicensing
{
$scaMode = " Enabled "
}
Write-Host
Write-Host " Status: " $scaMode
Write-Host
CONOUT " `nStatus: $scaMode "
CONOUT " `r "
$tokenFiles = $null
$tokenPath = " ${env:LOCALAPPDATA}\Microsoft\Office\16.0\Licensing "
If (Test-Path $ t o k e n P a t h )
@ -7047,12 +7180,12 @@ function PrintSharedComputerLicensing
@@ -7047,12 +7180,12 @@ function PrintSharedComputerLicensing
}
If ($null - E q $ t o k e n F i l e s )
{
Write-Host " No tokens found. "
CONOUT " No tokens found. "
Return
}
If ($tokenFiles.Length - E q 0 )
{
Write-Host " No tokens found. "
CONOUT " No tokens found. "
Return
}
$tokenFiles | ForEach `
@ -7086,16 +7219,9 @@ function PrintLicensesInformation
@@ -7086,16 +7219,9 @@ function PrintLicensesInformation
{
$licenseFiles = Get-ChildItem -Path $licensePath -Recurse | Where-Object { !$_.PSIsContainer }
}
If ($null - E q $ l i c e n s e F i l e s )
If ($null - E q $ l i c e n s e F i l e s - O r $ l i c e n s e F i l e s . L e n g t h - E q 0 )
{
Write-Host
Write-Host " No licenses found. "
Return
}
If ($licenseFiles.Length - E q 0 )
{
Write-Host
Write-Host " No licenses found. "
CONOUT " `nNo licenses found. "
Return
}
$licenseFiles | ForEach `
@ -7152,24 +7278,20 @@ function vNextDiagRun
@@ -7152,24 +7278,20 @@ function vNextDiagRun
Return
}
if ($All.IsPresent) { W r i t e - H o s t }
Write-Host " $line2 "
Write-Host " === Office vNext Status === "
Write-Host " $line2 "
Write-Host
Write-Host " ========== Mode per ProductReleaseId ========== "
& $isAll
CONOUT " $line2 "
CONOUT " === Office vNext Status === "
CONOUT " $line2 "
CONOUT " `n========== Mode per ProductReleaseId ========== "
PrintModePerPridFromRegistry
Write-Host
Write-Host " ========== Shared Computer Licensing ========== "
CONOUT " `n========== Shared Computer Licensing ========== "
PrintSharedComputerLicensing
Write-Host
Write-Host " ========== vNext licenses =========== "
CONOUT " `n========== vNext licenses =========== "
PrintLicensesInformation -Mode " NUL "
Write-Host
Write-Host " ========== Device licenses ========== "
CONOUT " `n========== Device licenses ========== "
PrintLicensesInformation -Mode " Device "
Write-Host " $line3 "
Write-Host
CONOUT " $line3 "
CONOUT " `r "
}
#endregion
@ -7252,13 +7374,13 @@ function PrintStateData {
@@ -7252,13 +7374,13 @@ function PrintStateData {
}
[string[]]$pwszStateString = $Marshal::PtrToStringUni($pwszStateData) -replace " ; " , " `n "
Write-Host " $pwszStateString "
CONOUT ( " $pwszStateString " )
$Marshal::FreeHGlobal($pwszStateData)
return $TRUE
}
function PrintLastActivationHRr esult {
function PrintLastActivationHResult {
$pdwLastHResult = 0
$cbSize = 0
@ -7271,12 +7393,34 @@ function PrintLastActivationHRresult {
@@ -7271,12 +7393,34 @@ function PrintLastActivationHRresult {
return $FALSE
}
Write-Host (" LastActivationHResult=0x{0:x8} " -f $Marshal::ReadInt32($pdwLastHResult))
CONOUT (" LastActivationHResult=0x{0:x8} " -f $Marshal::ReadInt32($pdwLastHResult))
$Marshal::FreeHGlobal($pdwLastHResult)
return $TRUE
}
function PrintLastActivationTime {
$pdwLastTime = 0
$cbSize = 0
if ($Win32::SLGetWindowsInformation(
" Security-SPP-LastWindowsActivationTime " ,
[ref]$null,
[ref]$cbSize,
[ref]$pdwLastTime
)) {
return $FALSE
}
$actTime = $Marshal::ReadInt64($pdwLastTime)
if ($actTime - n e 0 ) {
CONOUT (" LastActivationTime={0} " -f [DateTime]::FromFileTimeUtc($actTime).ToString(" yyyy/MM/dd:HH:mm:ss " ))
}
$Marshal::FreeHGlobal($pdwLastTime)
return $TRUE
}
function PrintIsWindowsGenuine {
$dwGenuine = 0
$ppwszGenuineStates = @(
@ -7292,9 +7436,9 @@ function PrintIsWindowsGenuine {
@@ -7292,9 +7436,9 @@ function PrintIsWindowsGenuine {
}
if ($dwGenuine - l t 5 ) {
Write-Host (" IsWindowsGenuine={0} " -f $ppwszGenuineStates[$dwGenuine])
CONOUT (" IsWindowsGenuine={0} " -f $ppwszGenuineStates[$dwGenuine])
} else {
Write-Host (" IsWindowsGenuine={0} " -f $dwGenuine)
CONOUT (" IsWindowsGenuine={0} " -f $dwGenuine)
}
return $TRUE
@ -7318,7 +7462,7 @@ function PrintDigitalLicenseStatus {
@@ -7318,7 +7462,7 @@ function PrintDigitalLicenseStatus {
[bool]$bDigitalLicense = $FALSE
$bDigitalLicense = (($dwReturnCode -ge 0) -and ($dwReturnCode -ne 1))
Write-Host (" IsDigitalLicense={0} " -f (BoolToWStr $bDigitalLicense))
CONOUT (" IsDigitalLicense={0} " -f (BoolToWStr $bDigitalLicense))
return $TRUE
}
@ -7336,7 +7480,7 @@ function PrintSubscriptionStatus {
@@ -7336,7 +7480,7 @@ function PrintSubscriptionStatus {
return $FALSE
}
Write-Host (" SubscriptionSupportedEdition={0} " -f (BoolToWStr $dwSupported))
CONOUT (" SubscriptionSupportedEdition={0} " -f (BoolToWStr $dwSupported))
$pStatus = $Marshal::AllocHGlobal($Marshal::SizeOf([Type]$SubStatus))
if ($Win32::ClipGetSubscriptionStatus([ref]$pStatus)) {
@ -7347,25 +7491,26 @@ function PrintSubscriptionStatus {
@@ -7347,25 +7491,26 @@ function PrintSubscriptionStatus {
$sStatus = $Marshal::PtrToStructure($pStatus, [Type]$SubStatus)
$Marshal::FreeHGlobal($pStatus)
Write-Host (" SubscriptionEnabled={0} " -f (BoolToWStr $sStatus.dwEnabled))
CONOUT (" SubscriptionEnabled={0} " -f (BoolToWStr $sStatus.dwEnabled))
if ($sStatus.dwEnabled - e q 0 ) {
return $TRUE
}
Write-Host (" SubscriptionSku={0} " -f $sStatus.dwSku)
Write-Host (" SubscriptionState={0} " -f $sStatus.dwState)
CONOUT (" SubscriptionSku={0} " -f $sStatus.dwSku)
CONOUT (" SubscriptionState={0} " -f $sStatus.dwState)
return $TRUE
}
function ClicRun
{
if ($All.IsPresent) { W r i t e - H o s t }
Write-Host " Client Licensing Check information: "
& $isAll
CONOUT " Client Licensing Check information: "
$null = PrintStateData
$null = PrintLastActivationHRresult
$null = PrintLastActivationHResult
$null = PrintLastActivationTime
$null = PrintIsWindowsGenuine
if ($DllDigital) {
@ -7376,20 +7521,16 @@ function ClicRun
@@ -7376,20 +7521,16 @@ function ClicRun
$null = PrintSubscriptionStatus
}
Write-Host " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
CONOUT " $line3 "
& $noAll
}
#endregion
$Host.UI.RawUI.WindowTitle = " Check Activation Status "
UnQuickEdit
if ($All.IsPresent) {
$B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B;clear;
}
$SysPath = " $env:SystemRoot\System32 "
if (Test-Path " $ e n v : S y s t e m R o o t \ S y s n a t i v e \ r e g . e x e " ) {
$SysPath = " $env:SystemRoot\Sysnative "
$B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B;
if (!$Pass.IsPresent) { c l e a r ; }
}
$wslp = " SoftwareLicensingProduct "
@ -7403,46 +7544,43 @@ $cSub = ($winbuild -GE 19041) -And (Select-String -Path "$SysPath\wbem\sppwmi.mo
@@ -7403,46 +7544,43 @@ $cSub = ($winbuild -GE 19041) -And (Select-String -Path "$SysPath\wbem\sppwmi.mo
$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 " )
$SLKeyPath = " Registry:: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
$NSKeyPath = " Registry:: HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
$SLKeyPath = " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL "
$NSKeyPath = " HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL "
'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ $null }
'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ $false }
$OsppHook = 1
try {gsv osppsvc -EA 1 | Out-Null} catch {$OsppHook = 0}
$offsvc = " osppsvc "
if ($NT7 - O r - N o t $ N T 6 ) { $ w i n s v c = " s p p s v c " } e l s e { $ w i n s v c = " s l s v c " }
if ($NT7 - O r - N o t $ N T 6 ) {
try {sasv sppsvc -EA 1} catch {}
}
else
{
try {sasv slsvc -EA 1} catch {}
}
try {gsv $winsvc -EA 1 | Out-Null; $WsppHook = 1} catch {$WsppHook = 0}
try {gsv $offsvc -EA 1 | Out-Null; $OsppHook = 1} catch {$OsppHook = 0}
DetectID $wslp $winApp ([ref]$cW1nd0ws)
DetectID $wslp $o15App ([ref]$c0ff1ce15)
DetectID $wslp $o14App ([ref]$c0ff1ce14)
if ($WsppHook - N E 0 ) {
try {sasv $winsvc -EA 1} catch {}
$cW1nd0ws = DetectID $wslp $winApp
$c0ff1ce15 = DetectID $wslp $o15App
$c0ff1ce14 = DetectID $wslp $o14App
}
if ($OsppHook - N E 0 ) {
try {sasv osppsvc -EA 1} catch {}
DetectID $oslp $o15App ([ref]$ospp15)
DetectID $oslp $o14App ([ref]$ospp14)
try {sasv $off svc -EA 1} catch {}
$ospp15 = DetectID $oslp $o15App
$ospp14 = DetectID $oslp $o14App
}
if ($null - N E $ c W 1 n d 0 w s )
if ($c W1n d0ws )
{
echoWindows
GetID $wslp $winApp | foreach -EA 1 {
GetResult $wslp $wsls $_
Write-Host " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
CONOUT " $line3 "
& $noAll
}
}
elseif ($NT6)
{
echoWindows
Write-Host
Write-Host " Error: product key not found. "
CONOUT " `nError: product key not found. "
}
if ($winbuild - G E 9 2 0 0 ) {
@ -7456,39 +7594,43 @@ if ($c0ff1ce15 -Or $ospp15) {
@@ -7456,39 +7594,43 @@ if ($c0ff1ce15 -Or $ospp15) {
$doMSG = 1
if ($null - N E $ c 0 f f 1 c e 1 5 ) {
if ($c0ff1ce15)
{
echoOffice
GetID $wslp $o15App | foreach -EA 1 {
GetResult $wslp $wsls $_
Write-Host " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
CONOUT " $line3 "
& $noAll
}
}
if ($null - N E $ c 0 f f 1 c e 1 4 ) {
if ($c0ff1ce14)
{
echoOffice
GetID $wslp $o14App | foreach -EA 1 {
GetResult $wslp $wsls $_
Write-Host " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
CONOUT " $line3 "
& $noAll
}
}
if ($null - N E $ o s p p 1 5 ) {
if ($ospp15)
{
echoOffice
GetID $oslp $o15App | foreach -EA 1 {
GetResult $oslp $osls $_
Write-Host " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
CONOUT " $line3 "
& $noAll
}
}
if ($null - N E $ o s p p 1 4 ) {
if ($ospp14)
{
echoOffice
GetID $oslp $o14App | foreach -EA 1 {
GetResult $oslp $osls $_
Write-Host " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
CONOUT " $line3 "
& $noAll
}
}