@ -1631,7 +1631,11 @@ 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] "
)
)
)
@ -1732,7 +1736,6 @@ 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%
@ -1742,7 +1745,6 @@ 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.
@ -2970,8 +2972,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' } | 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 { $_.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 { '!_allactid!' -contains $_.ID -and ($_.LicenseFamily -match 'Project' -or $_.LicenseFamily -match '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 %% # in ( %apps% ) do (
for %% # in ( %apps% ) do (
@ -6509,40 +6511,20 @@ 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 ) {
" ==== ERROR ====`r`n "
Write-Host " ==== ERROR ====`r`n "
" Windows PowerShell 1.0 is not supported by this script. "
Write-Host '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 ) {
" ==== ERROR ====`r`n "
Write-Host " ==== ERROR ====`r`n "
" Windows PowerShell is not running in Full Language Mode. "
Write-Host 'Windows PowerShell is not running in Full Language Mode.'
ExitScript 1
ExitScript 1
}
}
@ -6550,49 +6532,21 @@ $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]([wmi]'Win32_OperatingSystem=@' ).BuildNumber
$winbuild = [int](Get-WmiObject Win32_OperatingSystem ).BuildNumber
}
}
if ($winbuild - E Q 1 ) {
if ($winbuild - E Q 1 ) {
" ==== ERROR ====`r`n "
Write-Host " ==== ERROR ====`r`n "
" Could not detect Windows build. "
Write-Host '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 ) {
" ==== ERROR ====`r`n "
Write-Host " ==== ERROR ====`r`n "
" This build of Windows is not supported by this script. "
Write-Host '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
@ -6602,29 +6556,12 @@ $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
{
{
CONOUT " $line2 "
Write-Host " $line2 "
CONOUT " === Windows Status === "
Write-Host " === Windows Status === "
CONOUT " $line2 "
Write-Host " $line2 "
& $noAll
if (!$All.IsPresent) { W r i t e - H o s t }
}
}
function echoOffice
function echoOffice
@ -6633,22 +6570,18 @@ function echoOffice
return
return
}
}
& $isAll
if ($All.IsPresent) { W r i t e - H o s t }
CONOUT " $line2 "
Write-Host " $line2 "
CONOUT " === Office Status === "
Write-Host " === Office Status === "
CONOUT " $line2 "
Write-Host " $line2 "
& $noAll
if (!$All.IsPresent) { W r i t e - H o s t }
$script:doMSG = 0
$script:doMSG = 0
}
}
function strGetRegistry($strKey, $strName)
function strGetRegistry($strKey, $strName)
{
{
try {
Get-ItemProperty -EA 0 $strKey | select -EA 0 -Expand $strName
return [Microsoft.Win32.Registry]::GetValue($strKey, $strName, $null)
} catch {
return $null
}
}
}
function CheckOhook
function CheckOhook
@ -6679,57 +6612,55 @@ function CheckOhook
return
return
}
}
& $isAll
if ($All.IsPresent) { W r i t e - H o s t }
CONOUT " $line2 "
Write-Host " $line2 "
CONOUT " === Office Ohook Status === "
Write-Host " === Office Ohook Status === "
CONOUT " $line2 "
Write-Host " $line2 "
$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
& $noAll
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 }
}
}
#region WMI
#region WMI
function DetectID($strSLP, $strAppId)
function DetectID($strSLP, $strAppId, [ref]$strAppVar )
{
{
$ppk = (" AND PartialProductKey <> NULL) " , " ) " )[$All.IsPresent]
$fltr = " ApplicationID='$strAppId' "
$fltr = " SELECT ID FROM $strSLP WHERE (ApplicationID='$strAppId' "
if (!$All.IsPresent) {
$clause = $fltr + $ppk
$fltr = $fltr + " AND PartialProductKey <> NULL "
$sWmi = [wmisearcher]$clause
}
$sWmi.Options.Rewindable = $false
Get-WmiObject $strSLP ID -Filter $fltr -EA 0 | select ID -EA 0 | foreach {
return ($sWmi.Get().Count -GT 0)
$strAppVar.Value = 1
}
}
}
function GetID($strSLP, $strAppId)
function GetID($strSLP, $strAppId, $strProperty = " ID " )
{
{
$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 = $query + " IS NULL "
$fltr = " ApplicationID='$strAppId' AND PartialProductKey IS NULL "
$clause = $fltr + $isAdd
$clause = $fltr
$sWmi = [wmisearcher]$clause
if (-Not $ N T 5 ) {
$sWmi.Options.Rewindable = $false
$clause = $fltr + " AND LicenseDependsOn <> NULL "
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 + $noAdd
$clause = $fltr + " AND LicenseDependsOn IS NULL "
$sWmi = [wmisearcher]$clause
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
$sWmi.Options.Rewindable = $false
try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
}
}
}
}
$fltr = $query + " <> NULL "
$fltr = " ApplicationID='$strAppId' AND PartialProductKey <> NULL "
$clause = $fltr + $isAdd
$clause = $fltr
$sWmi = [wmisearcher]$clause
if (-Not $ N T 5 ) {
$sWmi.Options.Rewindable = $false
$clause = $fltr + " AND LicenseDependsOn <> NULL "
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 + $noAdd
$clause = $fltr + " AND LicenseDependsOn IS NULL "
$sWmi = [wmisearcher]$clause
Get-WmiObject $strSLP $strProperty -Filter $clause -EA 0 | select -Expand $strProperty -EA 0 | foreach {$IDs += $_}
$sWmi.Options.Rewindable = $false
try {$sWmi.Get() | select -Expand Properties -EA 0 | foreach {$IDs += $_.Value}} catch {}
}
}
return $IDs
return $IDs
@ -6766,45 +6697,38 @@ 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 }
}
}
CONOUT " `nSubscription information: "
Write-Host
CONOUT " Edition: $SubMsgEdition "
Write-Host " Subscription information: "
CONOUT " Type : $SubMsgType "
Write-Host " Edition: $SubMsgEdition "
CONOUT " Status : $SubMsgStatus "
Write-Host " Type : $SubMsgType "
CONOUT " Expiry : $SubMsgExpiry "
Write-Host " Status : $SubMsgStatus "
}
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
{
{
CONOUT " `nAutomatic VM Activation client information: "
Write-Host
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 ) ) {
CONOUT " Guest IAID: $IAID "
Write-Host " Guest IAID: $IAID "
} else {
} else {
CONOUT " Guest IAID: Not Available "
Write-Host " 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 ) ) {
CONOUT " Host machine name: $AutomaticVMActivationHostMachineName "
Write-Host " Host machine name: $AutomaticVMActivationHostMachineName "
} else {
} else {
CONOUT " Host machine name: Not Available "
Write-Host " 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')
CONOUT " Activation time: $EED UTC "
Write-Host " Activation time: $EED UTC "
} else {
} else {
CONOUT " Activation time: Not Available "
Write-Host " 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 ) ) {
CONOUT " Host Digital PID2: $AutomaticVMActivationHostDigitalPid2 "
Write-Host " Host Digital PID2: $AutomaticVMActivationHostDigitalPid2 "
} else {
} else {
CONOUT " Host Digital PID2: Not Available "
Write-Host " Host Digital PID2: Not Available "
}
}
}
}
@ -6834,30 +6758,32 @@ function DetectKmsHost
$KeyManagementServiceLowPriority = " Normal "
$KeyManagementServiceLowPriority = " Normal "
}
}
CONOUT " `nKey Management Service host information: "
Write-Host
CONOUT " Current count: $KeyManagementServiceCurrentCount "
Write-Host " Key Management Service host information: "
CONOUT " Listening on Port: $KeyManagementServiceListeningPort "
Write-Host " Current count: $KeyManagementServiceCurrentCount "
CONOUT " DNS publishing: $KeyManagementServiceDnsPublishing "
Write-Host " Listening on Port: $KeyManagementServiceListeningPort "
CONOUT " KMS priority: $KeyManagementServiceLowPriority "
Write-Host " DNS publishing: $KeyManagementServiceDnsPublishing "
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 ) ) {
CONOUT " `nKey Management Service cumulative requests received from clients: "
Write-Host
CONOUT " Total: $KeyManagementServiceTotalRequests "
Write-Host " Key Management Service cumulative requests received from clients: "
CONOUT " Failed: $KeyManagementServiceFailedRequests "
Write-Host " Total: $KeyManagementServiceTotalRequests "
CONOUT " Unlicensed: $KeyManagementServiceUnlicensedRequests "
Write-Host " Failed: $KeyManagementServiceFailedRequests "
CONOUT " Licensed: $KeyManagementServiceLicensedRequests "
Write-Host " Unlicensed: $KeyManagementServiceUnlicensedRequests "
CONOUT " Initial grace period: $KeyManagementServiceOOBGraceRequests "
Write-Host " Licensed: $KeyManagementServiceLicensedRequests "
CONOUT " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests "
Write-Host " Initial grace period: $KeyManagementServiceOOBGraceRequests "
CONOUT " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests "
Write-Host " Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests "
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 " Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests "
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 ) { 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 ] ) " }
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 ] ) " }
CONOUT " `r "
Write-Host
if ($LicenseStatus - N E 1 ) {
if ($LicenseStatus - N E 1 ) {
CONOUT " Please activate the product in order to update KMS client information values. "
Write-Host " Please activate the product in order to update KMS client information values. "
return
return
}
}
@ -6890,42 +6816,33 @@ function DetectKmsClient
}
}
}
}
CONOUT " Key Management Service client information: "
Write-Host " Key Management Service client information: "
CONOUT " Client Machine ID (CMID): $($objSvc.ClientMachineID) "
Write-Host " 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 ) {
CONOUT " $KmsDns "
Write-Host " $KmsDns "
CONOUT " Registered KMS machine name: KMS name not available "
Write-Host " Registered KMS machine name: KMS name not available "
} else {
} else {
CONOUT " $KmsReg "
Write-Host " $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 ) { 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 " }
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 " }
CONOUT " KMS machine extended PID: $KeyManagementServiceProductKeyID "
Write-Host " KMS machine extended PID: $KeyManagementServiceProductKeyID "
CONOUT " Activation interval: $VLActivationInterval minutes "
Write-Host " Activation interval: $VLActivationInterval minutes "
CONOUT " Renewal interval: $VLRenewalInterval 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 ) { 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 ($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 ) ) { 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 " }
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 " }
}
}
function GetResult($strSLP, $strSLS, $strID)
function GetResult($strSLP, $strSLS, $strID)
{
{
try
try {$objPrd = Get-WmiObject $strSLP -Filter " ID='$strID' " -EA 1} catch {return}
{
$objPrd | select -Expand Properties -EA 0 | foreach {
$objPrd = [wmisearcher]" SELECT * FROM $strSLP WHERE ID='$strID' "
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.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 " }
@ -6950,7 +6867,7 @@ function GetResult($strSLP, $strSLS, $strID)
$LicenseInf = " Licensed "
$LicenseInf = " Licensed "
$LicenseMsg = $null
$LicenseMsg = $null
if ($GracePeriodRemaining - E Q 0 ) {
if ($GracePeriodRemaining - E Q 0 ) {
$ExpireMsg = " The $prmnt is permanently activated. "
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 . " }
} 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 " }
@ -6971,9 +6888,8 @@ 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 " - 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 ($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 ($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 "
@ -6985,61 +6901,25 @@ 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 = strGetRegistry " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion " " DigitalProductId4 "
$dp4 = Get-ItemProperty -EA 0 " HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion " | select -EA 0 -Expand 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 ($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 ) {
if ($All.IsPresent) { W r i t e - H o s t }
try
Write-Host " Name: $Name "
{
Write-Host " Description: $Description "
$tmp = [wmisearcher]" SELECT RemainingWindowsReArmCount FROM $strSLS "
Write-Host " Activation ID: $ID "
$tmp.Options.Rewindable = $false
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.Get() | select -Expand Properties -EA 0 | foreach {set $_.Name $_.Value}
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.Dispose()
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 " }
catch
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 " }
}
}
$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')
CONOUT " Evaluation End Date: $EED UTC "
Write-Host " 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 ) {
@ -7051,27 +6931,16 @@ 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 ) { C O N O U T " ` n $ E x p i r e M s g " }
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 " }
return
return
}
}
try
$objSvc = Get-WmiObject $strSLS -EA 0
{
$objSvc = New-Object PSObject
if ($Vista) {
$wmiSvc = [wmisearcher]" SELECT * FROM $strSLS "
$objSvc | select -Expand Properties -EA 0 | foreach {
$wmiSvc.Options.Rewindable = $false
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.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 ) {
@ -7081,7 +6950,6 @@ 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
}
}
@ -7089,9 +6957,7 @@ function GetResult($strSLP, $strSLS, $strID)
DetectKmsClient
DetectKmsClient
}
}
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 ) { 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 " }
}
if ($chkSub) {
if ($chkSub) {
DetectSubscription
DetectSubscription
@ -7131,10 +6997,11 @@ 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 )
{
{
CONOUT " `nNo registry keys found. "
Write-Host
Write-Host " No registry keys found. "
Return
Return
}
}
CONOUT " `r "
Write-Host
$vNextPrids | ForEach `
$vNextPrids | ForEach `
{
{
$mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_
$mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_
@ -7144,7 +7011,7 @@ function PrintModePerPridFromRegistry
3 { $mode = " Device " ; Break }
3 { $mode = " Device " ; Break }
Default { $mode = " Legacy " ; Break }
Default { $mode = " Legacy " ; Break }
}
}
CONOUT " $_ = $mode "
Write-Host $_ = $mode
}
}
}
}
@ -7158,7 +7025,8 @@ 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 )
{
{
CONOUT " `nNo registry keys found. "
Write-Host
Write-Host " No registry keys found. "
Return
Return
}
}
$scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue
$scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue
@ -7170,8 +7038,9 @@ function PrintSharedComputerLicensing
{
{
$scaMode = " Enabled "
$scaMode = " Enabled "
}
}
CONOUT " `nStatus: $scaMode "
Write-Host
CONOUT " `r "
Write-Host " Status: " $scaMode
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 )
@ -7180,12 +7049,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 )
{
{
CONOUT " No tokens found. "
Write-Host " No tokens found. "
Return
Return
}
}
If ($tokenFiles.Length - E q 0 )
If ($tokenFiles.Length - E q 0 )
{
{
CONOUT " No tokens found. "
Write-Host " No tokens found. "
Return
Return
}
}
$tokenFiles | ForEach `
$tokenFiles | ForEach `
@ -7219,9 +7088,16 @@ 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 - O r $ l i c e n s e F i l e s . L e n g t h - E q 0 )
If ($null - E q $ l i c e n s e F i l e s )
{
{
CONOUT " `nNo licenses found. "
Write-Host
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 `
@ -7278,20 +7154,24 @@ function vNextDiagRun
Return
Return
}
}
& $isAll
if ($All.IsPresent) { W r i t e - H o s t }
CONOUT " $line2 "
Write-Host " $line2 "
CONOUT " === Office vNext Status === "
Write-Host " === Office vNext Status === "
CONOUT " $line2 "
Write-Host " $line2 "
CONOUT " `n========== Mode per ProductReleaseId ========== "
Write-Host
Write-Host " ========== Mode per ProductReleaseId ========== "
PrintModePerPridFromRegistry
PrintModePerPridFromRegistry
CONOUT " `n========== Shared Computer Licensing ========== "
Write-Host
Write-Host " ========== Shared Computer Licensing ========== "
PrintSharedComputerLicensing
PrintSharedComputerLicensing
CONOUT " `n========== vNext licenses =========== "
Write-Host
Write-Host " ========== vNext licenses =========== "
PrintLicensesInformation -Mode " NUL "
PrintLicensesInformation -Mode " NUL "
CONOUT " `n========== Device licenses ========== "
Write-Host
Write-Host " ========== Device licenses ========== "
PrintLicensesInformation -Mode " Device "
PrintLicensesInformation -Mode " Device "
CONOUT " $line3 "
Write-Host " $line3 "
CONOUT " `r "
Write-Host
}
}
#endregion
#endregion
@ -7374,13 +7254,13 @@ function PrintStateData {
}
}
[string[]]$pwszStateString = $Marshal::PtrToStringUni($pwszStateData) -replace " ; " , " `n "
[string[]]$pwszStateString = $Marshal::PtrToStringUni($pwszStateData) -replace " ; " , " `n "
CONOUT ( " $pwszStateString " )
Write-Host " $pwszStateString "
$Marshal::FreeHGlobal($pwszStateData)
$Marshal::FreeHGlobal($pwszStateData)
return $TRUE
return $TRUE
}
}
function PrintLastActivationHResult {
function PrintLastActivationHRr esult {
$pdwLastHResult = 0
$pdwLastHResult = 0
$cbSize = 0
$cbSize = 0
@ -7393,34 +7273,12 @@ function PrintLastActivationHResult {
return $FALSE
return $FALSE
}
}
CONOUT (" LastActivationHResult=0x{0:x8} " -f $Marshal::ReadInt32($pdwLastHResult))
Write-Host (" 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 = @(
@ -7436,9 +7294,9 @@ function PrintIsWindowsGenuine {
}
}
if ($dwGenuine - l t 5 ) {
if ($dwGenuine - l t 5 ) {
CONOUT (" IsWindowsGenuine={0} " -f $ppwszGenuineStates[$dwGenuine])
Write-Host (" IsWindowsGenuine={0} " -f $ppwszGenuineStates[$dwGenuine])
} else {
} else {
CONOUT (" IsWindowsGenuine={0} " -f $dwGenuine)
Write-Host (" IsWindowsGenuine={0} " -f $dwGenuine)
}
}
return $TRUE
return $TRUE
@ -7462,7 +7320,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))
CONOUT (" IsDigitalLicense={0} " -f (BoolToWStr $bDigitalLicense))
Write-Host (" IsDigitalLicense={0} " -f (BoolToWStr $bDigitalLicense))
return $TRUE
return $TRUE
}
}
@ -7480,7 +7338,7 @@ function PrintSubscriptionStatus {
return $FALSE
return $FALSE
}
}
CONOUT (" SubscriptionSupportedEdition={0} " -f (BoolToWStr $dwSupported))
Write-Host (" 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)) {
@ -7491,26 +7349,25 @@ function PrintSubscriptionStatus {
$sStatus = $Marshal::PtrToStructure($pStatus, [Type]$SubStatus)
$sStatus = $Marshal::PtrToStructure($pStatus, [Type]$SubStatus)
$Marshal::FreeHGlobal($pStatus)
$Marshal::FreeHGlobal($pStatus)
CONOUT (" SubscriptionEnabled={0} " -f (BoolToWStr $sStatus.dwEnabled))
Write-Host (" SubscriptionEnabled={0} " -f (BoolToWStr $sStatus.dwEnabled))
if ($sStatus.dwEnabled - e q 0 ) {
if ($sStatus.dwEnabled - e q 0 ) {
return $TRUE
return $TRUE
}
}
CONOUT (" SubscriptionSku={0} " -f $sStatus.dwSku)
Write-Host (" SubscriptionSku={0} " -f $sStatus.dwSku)
CONOUT (" SubscriptionState={0} " -f $sStatus.dwState)
Write-Host (" SubscriptionState={0} " -f $sStatus.dwState)
return $TRUE
return $TRUE
}
}
function ClicRun
function ClicRun
{
{
& $isAll
if ($All.IsPresent) { W r i t e - H o s t }
CONOUT " Client Licensing Check information: "
Write-Host " Client Licensing Check information: "
$null = PrintStateData
$null = PrintStateData
$null = PrintLastActivationHResult
$null = PrintLastActivationHRresult
$null = PrintLastActivationTime
$null = PrintIsWindowsGenuine
$null = PrintIsWindowsGenuine
if ($DllDigital) {
if ($DllDigital) {
@ -7521,16 +7378,20 @@ function ClicRun
$null = PrintSubscriptionStatus
$null = PrintSubscriptionStatus
}
}
CONOUT " $line3 "
Write-Host " $line3 "
& $noAll
if (!$All.IsPresent) { W r i t e - H o s t }
}
}
#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;
$B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B;clear;
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 "
@ -7544,43 +7405,46 @@ $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 = " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL "
$SLKeyPath = " Registry:: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
$NSKeyPath = " HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL "
$NSKeyPath = " Registry:: HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL"
'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ $false }
'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' | foreach {set $_ $null }
$offsvc = " osppsvc "
$OsppHook = 1
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 " }
try {gsv osppsvc -EA 1 | Out-Null} catch {$OsppHook = 0}
try {gsv $winsvc -EA 1 | Out-Null; $WsppHook = 1} catch {$WsppHook = 0}
if ($NT7 - O r - N o t $ N T 6 ) {
try {gsv $offsvc -EA 1 | Out-Null; $OsppHook = 1} catch {$OsppHook = 0}
try {sasv sppsvc -EA 1} catch {}
if ($WsppHook - N E 0 ) {
try {sasv $winsvc -EA 1} catch {}
$cW1nd0ws = DetectID $wslp $winApp
$c0ff1ce15 = DetectID $wslp $o15App
$c0ff1ce14 = DetectID $wslp $o14App
}
}
else
{
try {sasv slsvc -EA 1} catch {}
}
DetectID $wslp $winApp ([ref]$cW1nd0ws)
DetectID $wslp $o15App ([ref]$c0ff1ce15)
DetectID $wslp $o14App ([ref]$c0ff1ce14)
if ($OsppHook - N E 0 ) {
if ($OsppHook - N E 0 ) {
try {sasv $offsvc -EA 1} catch {}
try {sasv ospp svc -EA 1} catch {}
$ospp15 = DetectID $oslp $o15App
DetectID $oslp $o15App ([ref]$ospp15)
$ospp14 = DetectID $oslp $o14App
DetectID $oslp $o14App ([ref]$ospp14)
}
}
if ($cW1nd0ws)
if ($null - N E $ c W 1 n d 0 w s )
{
{
echoWindows
echoWindows
GetID $wslp $winApp | foreach -EA 1 {
GetID $wslp $winApp | foreach -EA 1 {
GetResult $wslp $wsls $_
GetResult $wslp $wsls $_
CONOUT " $line3 "
Write-Host " $line3 "
& $noAll
if (!$All.IsPresent) { W r i t e - H o s t }
}
}
}
}
elseif ($NT6)
elseif ($NT6)
{
{
echoWindows
echoWindows
CONOUT " `nError: product key not found. "
Write-Host
Write-Host " Error: product key not found. "
}
}
if ($winbuild - G E 9 2 0 0 ) {
if ($winbuild - G E 9 2 0 0 ) {
@ -7594,43 +7458,39 @@ if ($c0ff1ce15 -Or $ospp15) {
$doMSG = 1
$doMSG = 1
if ($c0ff1ce15)
if ($null - N E $ c 0 f f 1 c e 1 5 ) {
{
echoOffice
echoOffice
GetID $wslp $o15App | foreach -EA 1 {
GetID $wslp $o15App | foreach -EA 1 {
GetResult $wslp $wsls $_
GetResult $wslp $wsls $_
CONOUT " $line3 "
Write-Host " $line3 "
& $noAll
if (!$All.IsPresent) { W r i t e - H o s t }
}
}
}
}
if ($c0ff1ce14)
if ($null - N E $ c 0 f f 1 c e 1 4 ) {
{
echoOffice
echoOffice
GetID $wslp $o14App | foreach -EA 1 {
GetID $wslp $o14App | foreach -EA 1 {
GetResult $wslp $wsls $_
GetResult $wslp $wsls $_
CONOUT " $line3 "
Write-Host " $line3 "
& $noAll
if (!$All.IsPresent) { W r i t e - H o s t }
}
}
}
}
if ($ospp15)
if ($null - N E $ o s p p 1 5 ) {
{
echoOffice
echoOffice
GetID $oslp $o15App | foreach -EA 1 {
GetID $oslp $o15App | foreach -EA 1 {
GetResult $oslp $osls $_
GetResult $oslp $osls $_
CONOUT " $line3 "
Write-Host " $line3 "
& $noAll
if (!$All.IsPresent) { W r i t e - H o s t }
}
}
}
}
if ($ospp14)
if ($null - N E $ o s p p 1 4 ) {
{
echoOffice
echoOffice
GetID $oslp $o14App | foreach -EA 1 {
GetID $oslp $o14App | foreach -EA 1 {
GetResult $oslp $osls $_
GetResult $oslp $osls $_
CONOUT " $line3 "
Write-Host " $line3 "
& $noAll
if (!$All.IsPresent) { W r i t e - H o s t }
}
}
}
}
@ -8816,7 +8676,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 " (
if %winbuild% GEQ 17063 call : ced_edilist
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! "