From bc8ae03488691ce45752774cc4350a5e6e11cd33 Mon Sep 17 00:00:00 2001 From: DESKTOP-AJSJJMA\Admin Date: Mon, 7 Nov 2022 12:33:01 -0800 Subject: 1.7 --- .../Check-Activation-Status-wmi.cmd | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'MAS/Separate-Files-Version/Check-Activation-Status-wmi.cmd') diff --git a/MAS/Separate-Files-Version/Check-Activation-Status-wmi.cmd b/MAS/Separate-Files-Version/Check-Activation-Status-wmi.cmd index 6e9e948..ea350f0 100644 --- a/MAS/Separate-Files-Version/Check-Activation-Status-wmi.cmd +++ b/MAS/Separate-Files-Version/Check-Activation-Status-wmi.cmd @@ -72,8 +72,7 @@ if not %errorlevel%==0 ( echo: echo Error: This is not a correct file. It has LF line ending issue. echo: -echo Press any key to exit... -pause >nul +ping 127.0.0.1 -n 6 > nul popd exit /b ) @@ -362,7 +361,7 @@ exit /b function PrintModePerPridFromRegistry { $vNextRegkey = "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext" - $vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction Ignore | Select-Object -ExpandProperty 'property' | Where-Object -FilterScript {$_ -Ne 'InstalledGraceKey' -And $_ -Ne 'MigrationToV5Done' -And $_ -Ne 'test' -And $_ -Ne 'unknown'} + $vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction Ignore | Select-Object -ExpandProperty 'property' | Where-Object -FilterScript {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume"} If ($vNextPrids -Eq $null) { Write-Host "No registry keys found." @@ -457,15 +456,20 @@ function PrintLicensesInformation $license = (Get-Content -Encoding Unicode $_.FullName | ConvertFrom-Json).License $decodedLicense = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($license)) | ConvertFrom-Json $licenseType = $decodedLicense.LicenseType - $userId = $decodedLicense.Metadata.UserId - $identitiesRegkey = Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Identity\Identities\${userId}*" -ErrorAction Ignore + If ($null -Ne $decodedLicense.ExpiresOn) + { + $expiry = [DateTime]::Parse($decodedLicense.ExpiresOn, $null, 48) + } + Else + { + $expiry = New-Object DateTime + } $licenseState = $null If ((Get-Date) -Gt (Get-Date $decodedLicense.MetaData.NotAfter)) { $licenseState = "RFM" } - ElseIf (($decodedLicense.ExpiresOn -Eq $null) -Or - ((Get-Date) -Lt (Get-Date $decodedLicense.ExpiresOn))) + ElseIf ((Get-Date) -Lt (Get-Date $expiry)) { $licenseState = "Licensed" } @@ -483,11 +487,11 @@ function PrintLicensesInformation Acid = $decodedLicense.Acid; LicenseState = $licenseState; EntitlementStatus = $decodedLicense.Status; + EntitlementExpiration = $decodedLicense.ExpiresOn; ReasonCode = $decodedLicense.ReasonCode; NotBefore = $decodedLicense.Metadata.NotBefore; NotAfter = $decodedLicense.Metadata.NotAfter; NextRenewal = $decodedLicense.Metadata.RenewAfter; - Expiration = $decodedLicense.ExpiresOn; TenantId = $decodedLicense.Metadata.TenantId; } | ConvertTo-Json } @@ -502,11 +506,11 @@ function PrintLicensesInformation DeviceId = $decodedLicense.Metadata.DeviceId; LicenseState = $licenseState; EntitlementStatus = $decodedLicense.Status; + EntitlementExpiration = $decodedLicense.ExpiresOn; ReasonCode = $decodedLicense.ReasonCode; NotBefore = $decodedLicense.Metadata.NotBefore; NotAfter = $decodedLicense.Metadata.NotAfter; NextRenewal = $decodedLicense.Metadata.RenewAfter; - Expiration = $decodedLicense.ExpiresOn; TenantId = $decodedLicense.Metadata.TenantId; } | ConvertTo-Json } -- cgit v1.2.3