@@ -72,8 +72,7 @@ if not %errorlevel%==0 (
7272echo :
7373echo Error: This is not a correct file. It has LF line ending issue.
7474echo :
75- echo Press any key to exit...
76- pause > nul
75+ ping 127.0.0.1 -n 6 > nul
7776popd
7877exit /b
7978)
@@ -362,7 +361,7 @@ exit /b
362361function PrintModePerPridFromRegistry
363362{
364363 $vNextRegkey = " HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext"
365- $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' }
364+ $vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction Ignore | Select-Object -ExpandProperty 'property' | Where-Object -FilterScript {$_.ToLower() -like " *retail " -or $_.ToLower() -like " *volume " }
366365 If ($vNextPrids -Eq $null)
367366 {
368367 Write-Host " No registry keys found."
@@ -457,15 +456,20 @@ function PrintLicensesInformation
457456 $license = (Get-Content -Encoding Unicode $_.FullName | ConvertFrom-Json).License
458457 $decodedLicense = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($license)) | ConvertFrom-Json
459458 $licenseType = $decodedLicense.LicenseType
460- $userId = $decodedLicense.Metadata.UserId
461- $identitiesRegkey = Get-ItemProperty -Path " HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Identity\Identities\${userId}*" -ErrorAction Ignore
459+ If ($null -Ne $decodedLicense.ExpiresOn)
460+ {
461+ $expiry = [DateTime]::Parse($decodedLicense.ExpiresOn, $null, 48)
462+ }
463+ Else
464+ {
465+ $expiry = New-Object DateTime
466+ }
462467 $licenseState = $null
463468 If ((Get-Date) -Gt (Get-Date $decodedLicense.MetaData.NotAfter))
464469 {
465470 $licenseState = " RFM"
466471 }
467- ElseIf (($decodedLicense.ExpiresOn -Eq $null) -Or
468- ((Get-Date) -Lt (Get-Date $decodedLicense.ExpiresOn)))
472+ ElseIf ((Get-Date) -Lt (Get-Date $expiry))
469473 {
470474 $licenseState = " Licensed"
471475 }
@@ -483,11 +487,11 @@ function PrintLicensesInformation
483487 Acid = $decodedLicense.Acid;
484488 LicenseState = $licenseState;
485489 EntitlementStatus = $decodedLicense.Status;
490+ EntitlementExpiration = $decodedLicense.ExpiresOn;
486491 ReasonCode = $decodedLicense.ReasonCode;
487492 NotBefore = $decodedLicense.Metadata.NotBefore;
488493 NotAfter = $decodedLicense.Metadata.NotAfter;
489494 NextRenewal = $decodedLicense.Metadata.RenewAfter;
490- Expiration = $decodedLicense.ExpiresOn;
491495 TenantId = $decodedLicense.Metadata.TenantId;
492496 } | ConvertTo-Json
493497 }
@@ -502,11 +506,11 @@ function PrintLicensesInformation
502506 DeviceId = $decodedLicense.Metadata.DeviceId;
503507 LicenseState = $licenseState;
504508 EntitlementStatus = $decodedLicense.Status;
509+ EntitlementExpiration = $decodedLicense.ExpiresOn;
505510 ReasonCode = $decodedLicense.ReasonCode;
506511 NotBefore = $decodedLicense.Metadata.NotBefore;
507512 NotAfter = $decodedLicense.Metadata.NotAfter;
508513 NextRenewal = $decodedLicense.Metadata.RenewAfter;
509- Expiration = $decodedLicense.ExpiresOn;
510514 TenantId = $decodedLicense.Metadata.TenantId;
511515 } | ConvertTo-Json
512516 }
0 commit comments