@ -1631,11 +1631,7 @@ call :dk_color2 %Red% "Checking ClipSVC " %Blue% "[System
: : This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping.
: : This "WLMS" service was included in previous Eval editions (which were activable) to automatically shut down the system every hour after the evaluation period expired and prevent SPPSVC from stopping.
if exist " %SysPath% \wlms\wlms.exe " (
if exist " %SysPath% \wlms\wlms.exe " (
if %winbuild% LSS 9200 (
echo Checking Eval WLMS Service [Found]
echo Checking Eval WLMS Service [Found]
) else (
call : dk_color %Red% " Checking Eval WLMS Service [Found] "
)
)
)
@ -1736,6 +1732,7 @@ call :dk_color %Red% "Checking SPP tokens.dat [Not Found] [%toke
if %winbuild% GEQ 9200 if not exist " %SystemRoot% \Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum " (
if %winbuild% GEQ 9200 if not exist " %SystemRoot% \Servicing\Packages\Microsoft-Windows-*EvalEdition~*.mum " (
%psc% " Get-WmiObject -Query 'SELECT Description FROM SoftwareLicensingProduct WHERE PartialProductKey IS NOT NULL AND LicenseDependsOn IS NULL' | Select-Object -Property Description " %nul2% | findstr /i " KMS_ " %nul1% || (
for /f " delims= " %% a in ( ' %psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\' ) .State" %nul6% ') do (set taskinfo= %% a)
for /f " delims= " %% a in ( ' %psc% "(Get-ScheduledTask -TaskName 'SvcRestartTask' -TaskPath '\Microsoft\Windows\SoftwareProtectionPlatform\' ) .State" %nul6% ') do (set taskinfo= %% a)
echo !taskinfo! | find /i " Ready " %nul% || (
echo !taskinfo! | find /i " Ready " %nul% || (
reg delete " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform " /v " actionlist " /f %nul%
reg delete " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform " /v " actionlist " /f %nul%
@ -1745,6 +1742,7 @@ call :dk_color %Red% "Checking SvcRestartTask Status [!taskinfo!, Syste
if not defined error call : dk_color %Blue% " Reboot your machine using the restart option. "
if not defined error call : dk_color %Blue% " Reboot your machine using the restart option. "
)
)
)
)
)
: : This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers.
: : This code checks if SPP has permission access to tokens folder and required registry keys. It's often caused by gaming spoofers.
@ -2972,8 +2970,8 @@ set upk_result=0
call : dk_actid 0ff1ce15-a989-479d-af46-f275c6370663
call : dk_actid 0ff1ce15-a989-479d-af46-f275c6370663
if " %_actprojvis% " == " 1 " (
if " %_actprojvis% " == " 1 " (
for /f " delims= " %% a in ( ' %psc% "( Get-WmiObject -Query 'SELECT ID, Description, LicenseFamily FROM %spp% WHERE ApplicationID=''0ff1ce15-a989-479d-af46-f275c6370663'' AND PartialProductKey IS NOT NULL' | Where-Object { $_.LicenseFamily -notmatch 'Project' -and $_.LicenseFamily -notmatch 'Visio' }). ID" %nul6% ' ) do call set " _allactid= %% a !_allactid! "
for /f " delims= " %% a in ( ' %psc% "Get-WmiObject -Query 'SELECT ID, Description, LicenseFamily FROM %spp% WHERE ApplicationID=''0ff1ce15-a989-479d-af46-f275c6370663'' AND PartialProductKey IS NOT NULL' | Where-Object { $_.LicenseFamily -notmatch 'Project' -and $_.LicenseFamily -notmatch 'Visio' } | Select-Object -ExpandProperty ID" %nul6% ' ) do call set " _allactid= %% a !_allactid! "
for /f " delims= " %% a in ( ' %psc% "( Get-WmiObject -Query 'SELECT ID, Description, LicenseFamily FROM %spp% WHERE ApplicationID=''0ff1ce15-a989-479d-af46-f275c6370663'' AND PartialProductKey IS NOT NULL' | Where-Object { '!_allactid!' -contains $_.ID -and ($_.LicenseFamily -match 'Project' -or $_.LicenseFamily -match 'Visio' ) }) . ID" %nul6% ') do call set " _allactid=%% a !_allactid! "
for /f " delims= " %% a in ( ' %psc% "Get-WmiObject -Query 'SELECT ID, Description, LicenseFamily FROM %spp% WHERE ApplicationID=''0ff1ce15-a989-479d-af46-f275c6370663'' AND PartialProductKey IS NOT NULL' | Where-Object { '!_allactid!' -contains $_.ID -and ($_.LicenseFamily -match 'Project' -or $_.LicenseFamily -match 'Visio' ) } | Select-Object -ExpandProperty ID" %nul6% ') do call set " _allactid=%% a !_allactid! "
)
)
for %% # in ( %apps% ) do (
for %% # in ( %apps% ) do (
@ -6511,20 +6509,40 @@ mode 100, 36
goto dk_done
goto dk_done
: sppmgr :
: 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)
function ExitScript($ExitCode = 0)
{
{
Exit $ExitCode
Exit $ExitCode
}
}
if (-Not $ P S V e r s i o n T a b l e ) {
if (-Not $ P S V e r s i o n T a b l e ) {
Write-Host " ==== ERROR ====`r`n "
" ==== ERROR ====`r`n "
Write-Host 'Windows PowerShell 1.0 is not supported by this script.'
" Windows PowerShell 1.0 is not supported by this script. "
ExitScript 1
ExitScript 1
}
}
if ($ExecutionContext.SessionState.LanguageMode.value__ - N E 0 ) {
if ($ExecutionContext.SessionState.LanguageMode.value__ - N E 0 ) {
Write-Host " ==== ERROR ====`r`n "
" ==== ERROR ====`r`n "
Write-Host 'Windows PowerShell is not running in Full Language Mode.'
" Windows PowerShell is not running in Full Language Mode. "
ExitScript 1
ExitScript 1
}
}
@ -6532,21 +6550,49 @@ $winbuild = 1
try {
try {
$winbuild = [System.Diagnostics.FileVersionInfo]::GetVersionInfo(" $env:SystemRoot\System32\kernel32.dll " ).FileBuildPart
$winbuild = [System.Diagnostics.FileVersionInfo]::GetVersionInfo(" $env:SystemRoot\System32\kernel32.dll " ).FileBuildPart
} catch {
} catch {
$winbuild = [int](Get-WmiObject Win32_OperatingSystem ).BuildNumber
$winbuild = [int]([wmi]'Win32_OperatingSystem=@' ).BuildNumber
}
}
if ($winbuild - E Q 1 ) {
if ($winbuild - E Q 1 ) {
Write-Host " ==== ERROR ====`r`n "
" ==== ERROR ====`r`n "
Write-Host 'Could not detect Windows build.'
" Could not detect Windows build. "
ExitScript 1
ExitScript 1
}
}
if ($winbuild - L T 2 6 0 0 ) {
if ($winbuild - L T 2 6 0 0 ) {
Write-Host " ==== ERROR ====`r`n "
" ==== ERROR ====`r`n "
Write-Host 'This build of Windows is not supported by this script.'
" This build of Windows is not supported by this script. "
ExitScript 1
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
$NT6 = $winbuild -GE 6000
$NT7 = $winbuild -GE 7600
$NT7 = $winbuild -GE 7600
$NT9 = $winbuild -GE 9600
$NT9 = $winbuild -GE 9600
@ -6556,12 +6602,29 @@ $Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdenti
$line2 = " ============================================================ "
$line2 = " ============================================================ "
$line3 = " ____________________________________________________________ "
$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
function echoWindows
{
{
Write-Host " $line2 "
CONOUT " $line2 "
Write-Host " === Windows Status === "
CONOUT " === Windows Status === "
Write-Host " $line2 "
CONOUT " $line2 "
if (!$All.IsPresent) { W r i t e - H o s t }
& $noAll
}
}
function echoOffice
function echoOffice
@ -6570,18 +6633,22 @@ function echoOffice
return
return
}
}
if ($All.IsPresent) { W r i t e - H o s t }
& $isAll
Write-Host " $line2 "
CONOUT " $line2 "
Write-Host " === Office Status === "
CONOUT " === Office Status === "
Write-Host " $line2 "
CONOUT " $line2 "
if (!$All.IsPresent) { W r i t e - H o s t }
& $noAll
$script:doMSG = 0
$script:doMSG = 0
}
}
function strGetRegistry($strKey, $strName)
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
function CheckOhook
@ -6612,55 +6679,57 @@ function CheckOhook
return
return
}
}
if ($All.IsPresent) { W r i t e - H o s t }
& $isAll
Write-Host " $line2 "
CONOUT " $line2 "
Write-Host " === Office Ohook Status === "
CONOUT " === Office Ohook Status === "
Write-Host " $line2 "
CONOUT " $line2 "
Write-Host
$host.UI.WriteLine('Yellow', 'Black', " `r`nOhook for permanent Office activation is installed.`r`nYou can ignore the below mentioned Office activation status. " )
Write-Host -back 'Black' -fore 'Yellow' 'Ohook for permanent Office activation is installed.'
& $noAll
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 }
}
}
#region WMI
#region WMI
function DetectID($strSLP, $strAppId, [ref]$strAppVar )
function DetectID($strSLP, $strAppId)
{
{
$fltr = " ApplicationID='$strAppId' "
$ppk = (" AND PartialProductKey <> NULL) " , " ) " )[$All.IsPresent]
if (!$All.IsPresent) {
$fltr = " SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId' "
$fltr = $fltr + " AND PartialProductKey <> NULL "
$clause = $fltr + $ppk
}
$sWmi = [wmisearcher]$clause
Get-WmiObject $strSLP ID -Filter $fltr -EA 0 | select ID -EA 0 | foreach {
$sWmi.Options.Rewindable = $false
$strAppVar.Value = 1
return ($sWmi.Get().Count -GT 0)
}
}
}
function GetID($strSLP, $strAppId, $strProperty = " ID " )
function GetID($strSLP, $strAppId)
{
{
$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
$IDs = [Collections.ArrayList]@()
$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) {
if ($All.IsPresent) {
$fltr = " ApplicationID='$strAppId' AND PartialProductKey IS NULL "
$fltr = $query + " IS NULL "
$clause = $fltr
$clause = $fltr + $isAdd
if (-Not $ N T 5 ) {
$sWmi = [wmisearcher]$clause
$clause = $fltr + " AND LicenseDependsOn <> NULL "
$sWmi.Options.Rewindable = $false
}
try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
if (-Not $ N T 5 ) {
if (-Not $ N T 5 ) {
$clause = $fltr + " AND LicenseDependsOn IS NULL "
$clause = $fltr + $noAdd
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
$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 "
$fltr = $query + " <> NULL "
$clause = $fltr
$clause = $fltr + $isAdd
if (-Not $ N T 5 ) {
$sWmi = [wmisearcher]$clause
$clause = $fltr + " AND LicenseDependsOn <> NULL "
$sWmi.Options.Rewindable = $false
}
try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
if (-Not $ N T 5 ) {
if (-Not $ N T 5 ) {
$clause = $fltr + " AND LicenseDependsOn IS NULL "
$clause = $fltr + $noAdd
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
$sWmi = [wmisearcher]$clause
$sWmi.Options.Rewindable = $false
try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
}
}
return $IDs
return $IDs
@ -6697,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 }
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
CONOUT " `nSubscription information: "
Write-Host " Subscription information: "
CONOUT " Edition: $SubMsgEdition "
Write-Host " Edition: $SubMsgEdition "
CONOUT " Type : $SubMsgType "
Write-Host " Type : $SubMsgType "
CONOUT " Status : $SubMsgStatus "
Write-Host " Status : $SubMsgStatus "
CONOUT " Expiry : $SubMsgExpiry "
Write-Host " 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
function DetectAvmClient
{
{
Write-Host
CONOUT " `nAutomatic VM Activation client information: "
Write-Host " Automatic 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 ) ) {
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 {
} 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 ) ) {
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 {
} 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 " ) {
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')
$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 {
} 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 ) ) {
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 {
} else {
Write-Host " Host Digital PID2: Not Available "
CONOUT " Host Digital PID2: Not Available "
}
}
}
}
@ -6758,32 +6834,30 @@ function DetectKmsHost
$KeyManagementServiceLowPriority = " Normal "
$KeyManagementServiceLowPriority = " Normal "
}
}
Write-Host
CONOUT " `nKey Management Service host information: "
Write-Host " Key Management Service host information: "
CONOUT " Current count: $KeyManagementServiceCurrentCount "
Write-Host " Current count: $KeyManagementServiceCurrentCount "
CONOUT " Listening on Port: $KeyManagementServiceListeningPort "
Write-Host " Listening on Port: $KeyManagementServiceListeningPort "
CONOUT " DNS publishing: $KeyManagementServiceDnsPublishing "
Write-Host " DNS publishing: $KeyManagementServiceDnsPublishing "
CONOUT " KMS priority: $KeyManagementServiceLowPriority "
Write-Host " 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 ) ) {
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
CONOUT " `nKey Management Service cumulative requests received from clients: "
Write-Host " Key Management Service cumulative requests received from clients: "
CONOUT " Total: $KeyManagementServiceTotalRequests "
Write-Host " Total: $KeyManagementServiceTotalRequests "
CONOUT " Failed: $KeyManagementServiceFailedRequests "
Write-Host " Failed: $KeyManagementServiceFailedRequests "
CONOUT " Unlicensed: $KeyManagementServiceUnlicensedRequests "
Write-Host " Unlicensed: $KeyManagementServiceUnlicensedRequests "
CONOUT " Licensed: $KeyManagementServiceLicensedRequests "
Write-Host " Licensed: $KeyManagementServiceLicensedRequests "
CONOUT " Initial grace period: $KeyManagementServiceOOBGraceRequests "
Write-Host " Initial grace period: $KeyManagementServiceOOBGraceRequests "
CONOUT " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests "
Write-Host " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests "
CONOUT " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests "
Write-Host " 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 " }
Write-Host " Notification: $KeyManagementServiceNotificationRequests "
}
}
}
}
function DetectKmsClient
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 ] ) " }
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 ] ) " }
Write-Host
CONOUT " `r "
if ($LicenseStatus - N E 1 ) {
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
return
}
}
@ -6816,33 +6890,42 @@ function DetectKmsClient
}
}
}
}
Write-Host " Key Management Service client information: "
CONOUT " Key Management Service client information: "
Write-Host " Client Machine ID (CMID): $($objSvc.ClientMachineID) "
CONOUT " Client Machine ID (CMID): $($objSvc.ClientMachineID) "
if ($null - E Q $ K m s R e g ) {
if ($null - E Q $ K m s R e g ) {
Write-Host " $KmsDns "
CONOUT " $KmsDns "
Write-Host " Registered KMS machine name: KMS name not available "
CONOUT " Registered KMS machine name: KMS name not available "
} else {
} 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 " }
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 " }
Write-Host " KMS machine extended PID: $KeyManagementServiceProductKeyID "
CONOUT " KMS machine extended PID: $KeyManagementServiceProductKeyID "
Write-Host " Activation interval: $VLActivationInterval minutes "
CONOUT " Activation interval: $VLActivationInterval minutes "
Write-Host " Renewal interval: $VLRenewalInterval 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 ) { 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 ($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 ) ) { 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 (-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)
function GetResult($strSLP, $strSLS, $strID)
{
{
try {$objPrd = Get-WmiObject $strSLP -Filter " ID='$strID' " -EA 1} catch {return}
try
$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 }
$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)
$winID = ($ApplicationID -EQ $winApp)
$winPR = ($winID -And -Not $LicenseIsAddon)
$winPR = ($winID -And -Not $LicenseIsAddon)
$Vista = ($winID -And $NT6 -And -Not $NT7)
$Vista = ($winID -And $NT6 -And -Not $NT7)
$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
$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 " 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 " }
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 " }
@ -6867,7 +6950,7 @@ function GetResult($strSLP, $strSLS, $strID)
$LicenseInf = " Licensed "
$LicenseInf = " Licensed "
$LicenseMsg = $null
$LicenseMsg = $null
if ($GracePeriodRemaining - E Q 0 ) {
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 {
} else {
$LicenseMsg = " $_mTag activation expiration: $GracePeriodRemaining minute(s) ($_gpr day(s)) "
$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 " }
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 " }
@ -6888,8 +6971,9 @@ function GetResult($strSLP, $strSLS, $strID)
if ($LicenseStatus - E Q 5 - A n d - N o t $ N T 5 ) {
if ($LicenseStatus - E Q 5 - A n d - N o t $ N T 5 ) {
$LicenseInf = " Notification "
$LicenseInf = " Notification "
$LicenseMsg = " Notification Reason: $LicenseReason "
$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 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 ) ) {
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 "
$LicenseInf = " Unknown "
@ -6901,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 ) {
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 ) {
if ($null - N E $ d p 4 ) {
$ProductKeyChannel = ([System.Text.Encoding]::Unicode.GetString($dp4, 1016, 128)).Trim([char]$null)
$ProductKeyChannel = ([System.Text.Encoding]::Unicode.GetString($dp4, 1016, 128)).Trim([char]$null)
}
}
}
}
if ($All.IsPresent) { W r i t e - H o s t }
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 ) {
Write-Host " Name: $Name "
try
Write-Host " Description: $Description "
{
Write-Host " Activation ID: $ID "
$tmp = [wmisearcher]" SELECT RemainingWindowsReArmCount FROM $strSLS "
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 " }
$tmp.Options.Rewindable = $false
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 " }
$tmp.Get() | select -Expand Properties -EA 0 | foreach {set $_.Name $_.Value}
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 " }
$tmp.Dispose()
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 "
catch
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 " }
{
}
}
$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 " ) {
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')
$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 ) {
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 ) {
@ -6931,16 +7051,27 @@ function GetResult($strSLP, $strSLS, $strID)
$chkSLS = ($null -NE $PartialProductKey) -And ($null -NE $cKmsClient -Or $null -NE $cKmsHost -Or $chkSub)
$chkSLS = ($null -NE $PartialProductKey) -And ($null -NE $cKmsClient -Or $null -NE $cKmsHost -Or $chkSub)
if (!$chkSLS) {
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
return
}
}
$objSvc = Get-WmiObject $strSLS -EA 0
try
{
if ($Vista) {
$objSvc = New-Object PSObject
$objSvc | select -Expand Properties -EA 0 | foreach {
$wmiSvc = [wmisearcher]" SELECT * FROM $strSLS "
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 }
$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 ) {
if ($strSLS - E Q $ w s l s - A n d $ N T 9 ) {
@ -6950,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 $ 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
DetectKmsHost
}
}
@ -6957,7 +7089,9 @@ function GetResult($strSLP, $strSLS, $strID)
DetectKmsClient
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) {
if ($chkSub) {
DetectSubscription
DetectSubscription
@ -6997,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 " }
$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 )
If ($null - E q $ v N e x t P r i d s )
{
{
Write-Host
CONOUT " `nNo registry keys found. "
Write-Host " No registry keys found. "
Return
Return
}
}
Write-Host
CONOUT " `r "
$vNextPrids | ForEach `
$vNextPrids | ForEach `
{
{
$mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_
$mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_
@ -7011,7 +7144,7 @@ function PrintModePerPridFromRegistry
3 { $mode = " Device " ; Break }
3 { $mode = " Device " ; Break }
Default { $mode = " Legacy " ; Break }
Default { $mode = " Legacy " ; Break }
}
}
Write-Host $_ = $mode
CONOUT " $_ = $mode "
}
}
}
}
@ -7025,8 +7158,7 @@ function PrintSharedComputerLicensing
$scaPolicyValue = Get-ItemProperty -Path $scaPolicyKey -ErrorAction SilentlyContinue | Select-Object -ExpandProperty " SharedComputerLicensing " -ErrorAction SilentlyContinue
$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 )
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
CONOUT " `nNo registry keys found. "
Write-Host " No registry keys found. "
Return
Return
}
}
$scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue
$scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue
@ -7038,9 +7170,8 @@ function PrintSharedComputerLicensing
{
{
$scaMode = " Enabled "
$scaMode = " Enabled "
}
}
Write-Host
CONOUT " `nStatus: $scaMode "
Write-Host " Status: " $scaMode
CONOUT " `r "
Write-Host
$tokenFiles = $null
$tokenFiles = $null
$tokenPath = " ${env:LOCALAPPDATA}\Microsoft\Office\16.0\Licensing "
$tokenPath = " ${env:LOCALAPPDATA}\Microsoft\Office\16.0\Licensing "
If (Test-Path $ t o k e n P a t h )
If (Test-Path $ t o k e n P a t h )
@ -7049,12 +7180,12 @@ function PrintSharedComputerLicensing
}
}
If ($null - E q $ t o k e n F i l e s )
If ($null - E q $ t o k e n F i l e s )
{
{
Write-Host " No tokens found. "
CONOUT " No tokens found. "
Return
Return
}
}
If ($tokenFiles.Length - E q 0 )
If ($tokenFiles.Length - E q 0 )
{
{
Write-Host " No tokens found. "
CONOUT " No tokens found. "
Return
Return
}
}
$tokenFiles | ForEach `
$tokenFiles | ForEach `
@ -7088,16 +7219,9 @@ function PrintLicensesInformation
{
{
$licenseFiles = Get-ChildItem -Path $licensePath -Recurse | Where-Object { !$_.PSIsContainer }
$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
CONOUT " `nNo licenses found. "
Write-Host " No licenses found. "
Return
}
If ($licenseFiles.Length - E q 0 )
{
Write-Host
Write-Host " No licenses found. "
Return
Return
}
}
$licenseFiles | ForEach `
$licenseFiles | ForEach `
@ -7154,24 +7278,20 @@ function vNextDiagRun
Return
Return
}
}
if ($All.IsPresent) { W r i t e - H o s t }
& $isAll
Write-Host " $line2 "
CONOUT " $line2 "
Write-Host " === Office vNext Status === "
CONOUT " === Office vNext Status === "
Write-Host " $line2 "
CONOUT " $line2 "
Write-Host
CONOUT " `n========== Mode per ProductReleaseId ========== "
Write-Host " ========== Mode per ProductReleaseId ========== "
PrintModePerPridFromRegistry
PrintModePerPridFromRegistry
Write-Host
CONOUT " `n========== Shared Computer Licensing ========== "
Write-Host " ========== Shared Computer Licensing ========== "
PrintSharedComputerLicensing
PrintSharedComputerLicensing
Write-Host
CONOUT " `n========== vNext licenses =========== "
Write-Host " ========== vNext licenses =========== "
PrintLicensesInformation -Mode " NUL "
PrintLicensesInformation -Mode " NUL "
Write-Host
CONOUT " `n========== Device licenses ========== "
Write-Host " ========== Device licenses ========== "
PrintLicensesInformation -Mode " Device "
PrintLicensesInformation -Mode " Device "
Write-Host " $line3 "
CONOUT " $line3 "
Write-Host
CONOUT " `r "
}
}
#endregion
#endregion
@ -7254,13 +7374,13 @@ function PrintStateData {
}
}
[string[]]$pwszStateString = $Marshal::PtrToStringUni($pwszStateData) -replace " ; " , " `n "
[string[]]$pwszStateString = $Marshal::PtrToStringUni($pwszStateData) -replace " ; " , " `n "
Write-Host " $pwszStateString "
CONOUT ( " $pwszStateString " )
$Marshal::FreeHGlobal($pwszStateData)
$Marshal::FreeHGlobal($pwszStateData)
return $TRUE
return $TRUE
}
}
function PrintLastActivationHRr esult {
function PrintLastActivationHResult {
$pdwLastHResult = 0
$pdwLastHResult = 0
$cbSize = 0
$cbSize = 0
@ -7273,12 +7393,34 @@ function PrintLastActivationHRresult {
return $FALSE
return $FALSE
}
}
Write-Host (" LastActivationHResult=0x{0:x8} " -f $Marshal::ReadInt32($pdwLastHResult))
CONOUT (" LastActivationHResult=0x{0:x8} " -f $Marshal::ReadInt32($pdwLastHResult))
$Marshal::FreeHGlobal($pdwLastHResult)
$Marshal::FreeHGlobal($pdwLastHResult)
return $TRUE
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 {
function PrintIsWindowsGenuine {
$dwGenuine = 0
$dwGenuine = 0
$ppwszGenuineStates = @(
$ppwszGenuineStates = @(
@ -7294,9 +7436,9 @@ function PrintIsWindowsGenuine {
}
}
if ($dwGenuine - l t 5 ) {
if ($dwGenuine - l t 5 ) {
Write-Host (" IsWindowsGenuine={0} " -f $ppwszGenuineStates[$dwGenuine])
CONOUT (" IsWindowsGenuine={0} " -f $ppwszGenuineStates[$dwGenuine])
} else {
} else {
Write-Host (" IsWindowsGenuine={0} " -f $dwGenuine)
CONOUT (" IsWindowsGenuine={0} " -f $dwGenuine)
}
}
return $TRUE
return $TRUE
@ -7320,7 +7462,7 @@ function PrintDigitalLicenseStatus {
[bool]$bDigitalLicense = $FALSE
[bool]$bDigitalLicense = $FALSE
$bDigitalLicense = (($dwReturnCode -ge 0) -and ($dwReturnCode -ne 1))
$bDigitalLicense = (($dwReturnCode -ge 0) -and ($dwReturnCode -ne 1))
Write-Host (" IsDigitalLicense={0} " -f (BoolToWStr $bDigitalLicense))
CONOUT (" IsDigitalLicense={0} " -f (BoolToWStr $bDigitalLicense))
return $TRUE
return $TRUE
}
}
@ -7338,7 +7480,7 @@ function PrintSubscriptionStatus {
return $FALSE
return $FALSE
}
}
Write-Host (" SubscriptionSupportedEdition={0} " -f (BoolToWStr $dwSupported))
CONOUT (" SubscriptionSupportedEdition={0} " -f (BoolToWStr $dwSupported))
$pStatus = $Marshal::AllocHGlobal($Marshal::SizeOf([Type]$SubStatus))
$pStatus = $Marshal::AllocHGlobal($Marshal::SizeOf([Type]$SubStatus))
if ($Win32::ClipGetSubscriptionStatus([ref]$pStatus)) {
if ($Win32::ClipGetSubscriptionStatus([ref]$pStatus)) {
@ -7349,25 +7491,26 @@ function PrintSubscriptionStatus {
$sStatus = $Marshal::PtrToStructure($pStatus, [Type]$SubStatus)
$sStatus = $Marshal::PtrToStructure($pStatus, [Type]$SubStatus)
$Marshal::FreeHGlobal($pStatus)
$Marshal::FreeHGlobal($pStatus)
Write-Host (" SubscriptionEnabled={0} " -f (BoolToWStr $sStatus.dwEnabled))
CONOUT (" SubscriptionEnabled={0} " -f (BoolToWStr $sStatus.dwEnabled))
if ($sStatus.dwEnabled - e q 0 ) {
if ($sStatus.dwEnabled - e q 0 ) {
return $TRUE
return $TRUE
}
}
Write-Host (" SubscriptionSku={0} " -f $sStatus.dwSku)
CONOUT (" SubscriptionSku={0} " -f $sStatus.dwSku)
Write-Host (" SubscriptionState={0} " -f $sStatus.dwState)
CONOUT (" SubscriptionState={0} " -f $sStatus.dwState)
return $TRUE
return $TRUE
}
}
function ClicRun
function ClicRun
{
{
if ($All.IsPresent) { W r i t e - H o s t }
& $isAll
Write-Host " Client Licensing Check information: "
CONOUT " Client Licensing Check information: "
$null = PrintStateData
$null = PrintStateData
$null = PrintLastActivationHRresult
$null = PrintLastActivationHResult
$null = PrintLastActivationTime
$null = PrintIsWindowsGenuine
$null = PrintIsWindowsGenuine
if ($DllDigital) {
if ($DllDigital) {
@ -7378,20 +7521,16 @@ function ClicRun
$null = PrintSubscriptionStatus
$null = PrintSubscriptionStatus
}
}
Write-Host " $line3 "
CONOUT " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
& $noAll
}
}
#endregion
#endregion
$Host.UI.RawUI.WindowTitle = " Check Activation Status "
$Host.UI.RawUI.WindowTitle = " Check Activation Status "
UnQuickEdit
if ($All.IsPresent) {
if ($All.IsPresent) {
$B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B;clear;
$B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B;
}
if (!$Pass.IsPresent) { c l e a r ; }
$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 "
}
}
$wslp = " SoftwareLicensingProduct "
$wslp = " SoftwareLicensingProduct "
@ -7405,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 " )
$DllDigital = ($winbuild -GE 14393) -And (Test-Path " $SysPath\EditionUpgradeManagerObj.dll " )
$DllSubscription = ($winbuild -GE 14393) -And (Test-Path " $SysPath\Clipc.dll " )
$DllSubscription = ($winbuild -GE 14393) -And (Test-Path " $SysPath\Clipc.dll " )
$VLActTypes = @(" All " , " AD " , " KMS " , " Token " )
$VLActTypes = @(" All " , " AD " , " KMS " , " Token " )
$SLKeyPath = " Registry:: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
$SLKeyPath = " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL "
$NSKeyPath = " Registry:: HKEY_USERS\S-1-5-20\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
$offsvc = " osppsvc "
try {gsv osppsvc -EA 1 | Out-Null} catch {$OsppHook = 0}
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 {gsv $winsvc -EA 1 | Out-Null; $WsppHook = 1} catch {$WsppHook = 0}
try {sasv sppsvc -EA 1} catch {}
try {gsv $offsvc -EA 1 | Out-Null; $OsppHook = 1} catch {$OsppHook = 0}
}
else
{
try {sasv slsvc -EA 1} catch {}
}
DetectID $wslp $winApp ([ref]$cW1nd0ws)
if ($WsppHook - N E 0 ) {
DetectID $wslp $o15App ([ref]$c0ff1ce15)
try {sasv $winsvc -EA 1} catch {}
DetectID $wslp $o14App ([ref]$c0ff1ce14)
$cW1nd0ws = DetectID $wslp $winApp
$c0ff1ce15 = DetectID $wslp $o15App
$c0ff1ce14 = DetectID $wslp $o14App
}
if ($OsppHook - N E 0 ) {
if ($OsppHook - N E 0 ) {
try {sasv osppsvc -EA 1} catch {}
try {sasv $off svc -EA 1} catch {}
DetectID $oslp $o15App ([ref]$ospp15)
$ospp15 = DetectID $oslp $o15App
DetectID $oslp $o14App ([ref]$ospp14)
$ospp14 = DetectID $oslp $o14App
}
}
if ($null - N E $ c W 1 n d 0 w s )
if ($c W1n d0ws )
{
{
echoWindows
echoWindows
GetID $wslp $winApp | foreach -EA 1 {
GetID $wslp $winApp | foreach -EA 1 {
GetResult $wslp $wsls $_
GetResult $wslp $wsls $_
Write-Host " $line3 "
CONOUT " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
& $noAll
}
}
}
}
elseif ($NT6)
elseif ($NT6)
{
{
echoWindows
echoWindows
Write-Host
CONOUT " `nError: product key not found. "
Write-Host " Error: product key not found. "
}
}
if ($winbuild - G E 9 2 0 0 ) {
if ($winbuild - G E 9 2 0 0 ) {
@ -7458,39 +7594,43 @@ if ($c0ff1ce15 -Or $ospp15) {
$doMSG = 1
$doMSG = 1
if ($null - N E $ c 0 f f 1 c e 1 5 ) {
if ($c0ff1ce15)
{
echoOffice
echoOffice
GetID $wslp $o15App | foreach -EA 1 {
GetID $wslp $o15App | foreach -EA 1 {
GetResult $wslp $wsls $_
GetResult $wslp $wsls $_
Write-Host " $line3 "
CONOUT " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
& $noAll
}
}
}
}
if ($null - N E $ c 0 f f 1 c e 1 4 ) {
if ($c0ff1ce14)
{
echoOffice
echoOffice
GetID $wslp $o14App | foreach -EA 1 {
GetID $wslp $o14App | foreach -EA 1 {
GetResult $wslp $wsls $_
GetResult $wslp $wsls $_
Write-Host " $line3 "
CONOUT " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
& $noAll
}
}
}
}
if ($null - N E $ o s p p 1 5 ) {
if ($ospp15)
{
echoOffice
echoOffice
GetID $oslp $o15App | foreach -EA 1 {
GetID $oslp $o15App | foreach -EA 1 {
GetResult $oslp $osls $_
GetResult $oslp $osls $_
Write-Host " $line3 "
CONOUT " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
& $noAll
}
}
}
}
if ($null - N E $ o s p p 1 4 ) {
if ($ospp14)
{
echoOffice
echoOffice
GetID $oslp $o14App | foreach -EA 1 {
GetID $oslp $o14App | foreach -EA 1 {
GetResult $oslp $osls $_
GetResult $oslp $osls $_
Write-Host " $line3 "
CONOUT " $line3 "
if (!$All.IsPresent) { W r i t e - H o s t }
& $noAll
}
}
}
}
@ -8676,7 +8816,7 @@ if %winbuild% GEQ 10240 for /f "tokens=4" %%a in ('dism /online /english /Get-Ta
if %winbuild% LSS 10240 for /f " tokens=4 " %% a in ( ' %psc% "$f=[io.file]::ReadAllText('!_batp!' ) -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -GetTargetEditions;" ^| findstr /i /c:"Target Edition : "' ) do ( if defined _ptarget ( set " _ptarget= !_ptarget! %% a " ) else ( set " _ptarget= %% a " ) )
if %winbuild% LSS 10240 for /f " tokens=4 " %% a in ( ' %psc% "$f=[io.file]::ReadAllText('!_batp!' ) -split ':cbsxml\:.*';& ([ScriptBlock]::Create($f[1])) -GetTargetEditions;" ^| findstr /i /c:"Target Edition : "' ) do ( if defined _ptarget ( set " _ptarget= !_ptarget! %% a " ) else ( set " _ptarget= %% a " ) )
if %winbuild% GEQ 10240 if not exist " %SystemRoot% \Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum " (
if %winbuild% GEQ 10240 if not exist " %SystemRoot% \Servicing\Packages\Microsoft-Windows-Server*Edition~*.mum " (
call : ced_edilist
if %winbuild% GEQ 17063 call : ced_edilist
if /i " %osedition:~0,4% " == " Core " set _pro = Professional
if /i " %osedition:~0,4% " == " Core " set _pro = Professional
if /i " %osedition% " == " CoreN " set _pro = ProfessionalN
if /i " %osedition% " == " CoreN " set _pro = ProfessionalN
set " _dtarget= %_dtarget% !_wtarget! !_pro! "
set " _dtarget= %_dtarget% !_wtarget! !_pro! "