Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!-- : class="re0">Begin batch script
- @setlocal DisableDelayedExpansion
- @echo off
- :: change to 1 to use VBScript to access WMI
- :: automatically enabled if wmic.exe is not installed
- set WMI_VBS=0
- :: change to 1 to use Windows PowerShell to access WMI
- :: automatically enabled if wmic.exe and VBScript are not installed
- set WMI_PS=0
- :: WMI_PS takes precedence over wmic.exe and WMI_VBS
- :: WMI_VBS takes precedence over wmic.exe
- @cls
- set _args=
- set _args=%*
- if not defined _args goto :NoProgArgs
- for %%A in (%_args%) do (
- if /i "%%A"=="-wow" set _rel1=1
- if /i "%%A"=="-arm" set _rel2=1
- )
- :NoProgArgs
- set "_cmdf=%~f0"
- if exist "%SystemRoot%\Sysnative\cmd.exe" if not defined _rel1 (
- setlocal EnableDelayedExpansion
- start %SystemRoot%\Sysnative\cmd.exe /c ""!_cmdf!" -wow"
- exit /b
- )
- if exist "%SystemRoot%\SysArm32\cmd.exe" if /i %PROCESSOR_ARCHITECTURE%==AMD64 if not defined _rel2 (
- setlocal EnableDelayedExpansion
- start %SystemRoot%\SysArm32\cmd.exe /c ""!_cmdf!" -arm"
- exit /b
- )
- color 07
- set "SysPath=%SystemRoot%\System32"
- set "Path=%SystemRoot%\System32;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0\"
- if exist "%SystemRoot%\Sysnative\reg.exe" (
- set "SysPath=%SystemRoot%\Sysnative"
- set "Path=%SystemRoot%\Sysnative;%SystemRoot%\Sysnative\Wbem;%SystemRoot%\Sysnative\WindowsPowerShell\v1.0\;%Path%"
- )
- set "line2=************************************************************"
- set "line3=____________________________________________________________"
- set "_err===== ERROR ===="
- set "_psc=powershell -nop -c"
- set _acc=WMIC
- set _cwmi=0
- for %%# in (wmic.exe) do @if not "%%~$PATH:#"=="" (
- wmic path Win32_ComputerSystem get CreationClassName /value 2>nul | find /i "ComputerSystem" 1>nul && set _cwmi=1
- )
- set _prsh=1
- for %%# in (powershell.exe) do @if "%%~$PATH:#"=="" set _prsh=0
- if not exist "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" set _prsh=0
- set _WSH=1
- reg query "HKCU\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
- reg query HKU\S-1-5-19 1>nul 2>nul && (
- reg query "HKLM\SOFTWARE\Microsoft\Windows Script Host\Settings" /v Enabled 2>nul | find /i "0x0" 1>nul && (set _WSH=0)
- )
- if %_cwmi% EQU 0 if %WMI_PS% EQU 0 if %_WSH% EQU 1 if exist "%SysPath%\vbscript.dll" set WMI_VBS=1
- if %_cwmi% EQU 0 if %WMI_VBS% EQU 0 if %_prsh% EQU 1 set WMI_PS=1
- if %_cwmi% EQU 0 if %WMI_VBS% EQU 0 if %WMI_PS% EQU 0 goto :E_WMI
- if %WMI_VBS% NEQ 0 if %WMI_PS% EQU 0 (
- if %_WSH% EQU 0 goto :E_WSH
- if not exist "%SysPath%\vbscript.dll" goto :E_VBS
- set _cwmi=0
- set _acc=VBS
- )
- if %WMI_PS% NEQ 0 (
- if %_prsh% EQU 0 goto :E_PWS
- 2>nul %_psc% $ExecutionContext.SessionState.LanguageMode | find /i "Full" 1>nul || goto :E_PLM
- set _cwmi=0
- set WMI_VBS=0
- set _acc=PS
- )
- title Check Activation Status [%_acc%]
- set "_csg=cscript.exe //NoLogo //Job:WmiMulti "%~nx0?.wsf""
- set "_csq=cscript.exe //NoLogo //Job:WmiQuery "%~nx0?.wsf""
- set "_csx=cscript.exe //NoLogo //Job:XPDT "%~nx0?.wsf""
- set wslp=SoftwareLicensingProduct
- set wsls=SoftwareLicensingService
- set oslp=OfficeSoftwareProtectionProduct
- set osls=OfficeSoftwareProtectionService
- set winApp=55c92734-d682-4d71-983e-d6ec3f16059f
- set o14App=59a52881-a989-479d-af46-f275c6370663
- set o15App=0ff1ce15-a989-479d-af46-f275c6370663
- for %%# in (wspp_get,ospp_get,cW1nd0ws,sppw,c0ff1ce15,sppo,osppsvc,ospp14,ospp15) do set "%%#="
- for /f "tokens=6 delims=[]. " %%# in ('ver') do set winbuild=%%#
- set "wspp_get=Description, DiscoveredKeyManagementServiceMachineName, DiscoveredKeyManagementServiceMachinePort, EvaluationEndDate, GracePeriodRemaining, ID, KeyManagementServiceMachine, KeyManagementServicePort, KeyManagementServiceProductKeyID, LicenseStatus, LicenseStatusReason, Name, PartialProductKey, ProductKeyID, VLActivationInterval, VLRenewalInterval"
- set "ospp_get=%wspp_get%"
- if %winbuild% GEQ 9200 set "wspp_get=%wspp_get%, KeyManagementServiceLookupDomain, VLActivationTypeEnabled"
- if %winbuild% GEQ 9600 set "wspp_get=%wspp_get%, DiscoveredKeyManagementServiceMachineIpAddress, ProductKeyChannel"
- set "_work=%~dp0"
- set "_batf=%~f0"
- set "_batp=%_batf:'=''%"
- set "_Local=%LocalAppData%"
- set _vNextLs=0
- setlocal EnableDelayedExpansion
- dir /b /s /a:-d "!_Local!\Microsoft\Office\Licenses\*" 1>nul 2>nul && set _vNextLs=1
- dir /b /s /a:-d "!ProgramData!\Microsoft\Office\Licenses\*" 1>nul 2>nul && set _vNextLs=1
- pushd "!_work!"
- setlocal DisableDelayedExpansion
- if %winbuild% LSS 9200 if not exist "%SystemRoot%\servicing\Packages\Microsoft-Windows-PowerShell-WTR-Package~*.mum" set _vNextLs=0
- set OsppHook=1
- sc query osppsvc >nul 2>&1
- if %errorlevel% EQU 1060 set OsppHook=0
- net start sppsvc /y >nul 2>&1
- call :casWpkey %wslp% %winApp% cW1nd0ws sppw
- if %winbuild% GEQ 9200 call :casWpkey %wslp% %o15App% c0ff1ce15 sppo
- if %OsppHook% NEQ 0 (
- net start osppsvc /y >nul 2>&1
- call :casWpkey %oslp% %o14App% osppsvc ospp14
- if %winbuild% LSS 9200 call :casWpkey %oslp% %o15App% osppsvc ospp15
- )
- echo %line2%
- echo *** Windows Status ***
- echo %line2%
- if not defined cW1nd0ws (
- echo.
- echo Error: product key not found.
- goto :casWcon
- )
- set winID=1
- call :casWqr %wslp% %winApp% ID
- for /f "tokens=2 delims==" %%# in ('%_qr%') do (
- set "chkID=%%#"
- call :casWdet "%wslp%" "%wsls%" "%wspp_get%"
- call :casWout
- echo %line3%
- echo.
- )
- :casWcon
- set winID=0
- set verbose=1
- if not defined c0ff1ce15 (
- if defined osppsvc goto :casWospp
- goto :casWend
- )
- echo %line2%
- echo *** Office Status ***
- echo %line2%
- call :casWqr %wslp% %o15App% ID
- for /f "tokens=2 delims==" %%# in ('%_qr%') do (
- set "chkID=%%#"
- call :casWdet "%wslp%" "%wsls%" "%wspp_get%"
- call :casWout
- echo %line3%
- echo.
- )
- set verbose=0
- if defined osppsvc goto :casWospp
- goto :casWend
- :casWospp
- if %verbose% EQU 1 (
- echo %line2%
- echo *** Office Status ***
- echo %line2%
- )
- call :casWqr %oslp% %o15App% ID
- if defined ospp15 for /f "tokens=2 delims==" %%# in ('%_qr%') do (
- set "chkID=%%#"
- call :casWdet "%oslp%" "%osls%" "%ospp_get%"
- call :casWout
- echo %line3%
- echo.
- )
- call :casWqr %oslp% %o14App% ID
- if defined ospp14 for /f "tokens=2 delims==" %%# in ('%_qr%') do (
- set "chkID=%%#"
- call :casWdet "%oslp%" "%osls%" "%ospp_get%"
- call :casWout
- echo %line3%
- echo.
- )
- goto :casWend
- :casWpkey
- call :casWqr %1 %2 ID
- %_qr% 2>nul | findstr /i ID 1>nul && (set %3=1&set %4=1)
- exit /b
- :casWdet
- for %%# in (%~3) do set "%%#="
- if /i %~1==%oslp% for %%# in (DiscoveredKeyManagementServiceMachineIpAddress, KeyManagementServiceLookupDomain, ProductKeyChannel, VLActivationTypeEnabled) do set "%%#="
- set "cKmsClient="
- set "cTblClient="
- set "cAvmClient="
- set "ExpireMsg="
- set "_xpr="
- call :casWml "%~1" "%chkID%" "%~3"
- for /f "tokens=* delims=" %%# in ('%_qr%') do set "%%#"
- set /a _gpr=(GracePeriodRemaining+1440-1)/1440
- echo %Description%| findstr /i VOLUME_KMSCLIENT 1>nul && (set cKmsClient=1&set _mTag=Volume)
- echo %Description%| findstr /i TIMEBASED_ 1>nul && (set cTblClient=1&set _mTag=Timebased)
- echo %Description%| findstr /i VIRTUAL_MACHINE_ACTIVATION 1>nul && (set cAvmClient=1&set _mTag=Automatic VM)
- cmd /c exit /b %LicenseStatusReason%
- set "LicenseReason=%=ExitCode%"
- set "LicenseMsg=Time remaining: %GracePeriodRemaining% minute(s) (%_gpr% day(s))"
- if %_gpr% GEQ 1 if %_WSH% EQU 1 if exist "%SysPath%\vbscript.dll" (
- for /f "tokens=* delims=" %%# in ('%_csx% %GracePeriodRemaining%') do set "_xpr=%%#"
- )
- if %_gpr% GEQ 1 if %_prsh% EQU 1 if not defined _xpr (
- for /f "tokens=* delims=" %%# in ('%_psc% "$([DateTime]::Now.addMinutes(%GracePeriodRemaining%)).ToString('yyyy-MM-dd hh:mm:ss tt')" 2^>nul') do set "_xpr=%%#"
- title Check Activation Status [%_acc%]
- )
- if %LicenseStatus% EQU 0 (
- set "License=Unlicensed"
- set "LicenseMsg="
- )
- if %LicenseStatus% EQU 1 (
- set "License=Licensed"
- set "LicenseMsg="
- if %GracePeriodRemaining% EQU 0 (
- if %winID% EQU 1 (set "ExpireMsg=The machine is permanently activated.") else (set "ExpireMsg=The product is permanently activated.")
- ) else (
- set "LicenseMsg=%_mTag% activation expiration: %GracePeriodRemaining% minute(s) (%_gpr% day(s))"
- if defined _xpr set "ExpireMsg=%_mTag% activation will expire %_xpr%"
- )
- )
- if %LicenseStatus% EQU 2 (
- set "License=Initial grace period"
- if defined _xpr set "ExpireMsg=Initial grace period ends %_xpr%"
- )
- if %LicenseStatus% EQU 3 (
- set "License=Additional grace period (KMS license expired or hardware out of tolerance)"
- if defined _xpr set "ExpireMsg=Additional grace period ends %_xpr%"
- )
- if %LicenseStatus% EQU 4 (
- set "License=Non-genuine grace period."
- if defined _xpr set "ExpireMsg=Non-genuine grace period ends %_xpr%"
- )
- if %LicenseStatus% EQU 6 (
- set "License=Extended grace period"
- if defined _xpr set "ExpireMsg=Extended grace period ends %_xpr%"
- )
- if %LicenseStatus% EQU 5 (
- set "License=Notification"
- if "%LicenseReason%"=="C004F200" (set "LicenseMsg=Notification Reason: 0xC004F200 (non-genuine)."
- ) else if "%LicenseReason%"=="C004F009" (set "LicenseMsg=Notification Reason: 0xC004F009 (grace time expired)."
- ) else (set "LicenseMsg=Notification Reason: 0x%LicenseReason%"
- )
- )
- if %LicenseStatus% GTR 6 (
- set "License=Unknown"
- set "LicenseMsg="
- )
- if not defined cKmsClient exit /b
- if %KeyManagementServicePort%==0 set KeyManagementServicePort=1688
- set "KmsReg=Registered KMS machine name: %KeyManagementServiceMachine%:%KeyManagementServicePort%"
- if "%KeyManagementServiceMachine%"=="" set "KmsReg=Registered KMS machine name: KMS name not available"
- if %DiscoveredKeyManagementServiceMachinePort%==0 set DiscoveredKeyManagementServiceMachinePort=1688
- set "KmsDns=KMS machine name from DNS: %DiscoveredKeyManagementServiceMachineName%:%DiscoveredKeyManagementServiceMachinePort%"
- if "%DiscoveredKeyManagementServiceMachineName%"=="" set "KmsDns=DNS auto-discovery: KMS name not available"
- call :casWml "%~2" "ClientMachineID, KeyManagementServiceHostCaching"
- for /f "tokens=* delims=" %%# in ('%_qr%') do set "%%#"
- if /i %KeyManagementServiceHostCaching%==True (set KeyManagementServiceHostCaching=Enabled) else (set KeyManagementServiceHostCaching=Disabled)
- if %winbuild% LSS 9200 exit /b
- if /i %~1==%oslp% exit /b
- if "%KeyManagementServiceLookupDomain%"=="" set "KeyManagementServiceLookupDomain="
- if %VLActivationTypeEnabled% EQU 3 (
- set VLActivationType=Token
- ) else if %VLActivationTypeEnabled% EQU 2 (
- set VLActivationType=KMS
- ) else if %VLActivationTypeEnabled% EQU 1 (
- set VLActivationType=AD
- ) else (
- set VLActivationType=All
- )
- if %winbuild% LSS 9600 exit /b
- if "%DiscoveredKeyManagementServiceMachineIpAddress%"=="" set "DiscoveredKeyManagementServiceMachineIpAddress=not available"
- exit /b
- :casWout
- echo.
- echo Name: %Name%
- echo Description: %Description%
- echo Activation ID: %ID%
- echo Extended PID: %ProductKeyID%
- if defined ProductKeyChannel echo Product Key Channel: %ProductKeyChannel%
- echo Partial Product Key: %PartialProductKey%
- echo License Status: %License%
- if defined LicenseMsg echo %LicenseMsg%
- if not %LicenseStatus%==0 if not %EvaluationEndDate:~0,8%==16010101 echo Evaluation End Date: %EvaluationEndDate:~0,4%-%EvaluationEndDate:~4,2%-%EvaluationEndDate:~6,2% %EvaluationEndDate:~8,2%:%EvaluationEndDate:~10,2% UTC
- if not defined cKmsClient (
- if defined ExpireMsg echo.&echo. %ExpireMsg%
- exit /b
- )
- if defined VLActivationTypeEnabled echo Configured Activation Type: %VLActivationType%
- echo.
- if not %LicenseStatus%==1 (
- echo Please activate the product in order to update KMS client information values.
- exit /b
- )
- echo Most recent activation information:
- echo Key Management Service client information
- echo. Client Machine ID (CMID): %ClientMachineID%
- echo. %KmsDns%
- echo. %KmsReg%
- if defined DiscoveredKeyManagementServiceMachineIpAddress echo. KMS machine IP address: %DiscoveredKeyManagementServiceMachineIpAddress%
- echo. KMS machine extended PID: %KeyManagementServiceProductKeyID%
- echo. Activation interval: %VLActivationInterval% minutes
- echo. Renewal interval: %VLRenewalInterval% minutes
- echo. KMS host caching: %KeyManagementServiceHostCaching%
- if defined KeyManagementServiceLookupDomain echo. KMS SRV record lookup domain: %KeyManagementServiceLookupDomain%
- if defined ExpireMsg echo.&echo. %ExpireMsg%
- exit /b
- :casWend
- if %_vNextLs% EQU 1 if %_prsh% EQU 1 (
- echo %line2%
- echo *** Office vNext Status ***
- echo %line2%
- setlocal EnableDelayedExpansion
- %_psc% "$f=[IO.File]::ReadAllText('!_batp!') -split ':vNextDiag\:.*';iex ($f[1])"
- title Check Activation Status [%_acc%]
- echo %line3%
- echo.
- )
- goto :casWexit
- :E_VBS
- echo %_err%
- echo VBScript engine is not installed.
- echo It is required for this script to work.
- goto :casWexit
- :E_WSH
- echo %_err%
- echo Windows Script Host is disabled.
- echo It is required for this script to work.
- goto :casWexit
- :E_PWS
- echo %_err%
- echo Windows PowerShell is not installed.
- echo It is required for this script to work.
- goto :casWexit
- :E_PLM
- echo %_err%
- echo Windows PowerShell is not properly responding.
- echo check if it is working, and not locked in Constrained Language Mode.
- goto :casWexit
- :E_WMI
- echo %_err%
- echo This script require one of these to work:
- echo wmic.exe tool
- echo VBScript engine
- echo Windows PowerShell
- goto :casWexit
- :casWexit
- echo.
- echo Press any key to exit.
- pause >nul
- exit /b
- :casWqr
- if %_cwmi% EQU 1 (
- set "_qr=wmic path %1 where "ApplicationID='%2' and PartialProductKey is not null" get %3 /value"
- exit /b
- )
- if %WMI_VBS% NEQ 0 (
- set "_qr=%_csq% %1 "ApplicationID='%2' and PartialProductKey is not null" %3"
- exit /b
- )
- set _qr=%_psc% "(([WMISEARCHER]'SELECT %3 FROM %1 WHERE ApplicationID=''%2'' AND PartialProductKey IS NOT NULL').Get()).Properties | %% {$_.Name+'='+$_.Value}"
- exit /b
- :casWml
- set "_mlxt="
- set "_mlxt=%~3"
- if %_cwmi% EQU 1 (
- set "_qr="wmic path %~1 get %~2 /value" ^| findstr ^="
- if defined _mlxt set "_qr="wmic path %~1 where ID='%~2' get %~3 /value" ^| findstr ^="
- exit /b
- )
- if %WMI_VBS% NEQ 0 (
- set "_qr=%_csg% %~1 "%~2""
- if defined _mlxt set "_qr=%_csg% %~1 "ID='%~2'" "%~3""
- exit /b
- )
- set _qr=%_psc% "(([WMISEARCHER]'SELECT %~2 FROM %~1').Get()).Properties | %% {$_.Name+'='+$_.Value}"
- if defined _mlxt set _qr=%_psc% "(([WMISEARCHER]'SELECT %~3 FROM %~1 WHERE ID=''%~2''').Get()).Properties | %% {$_.Name+'='+$_.Value}"
- exit /b
- :vNextDiag:
- 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 {$_.ToLower() -like "*retail" -or $_.ToLower() -like "*volume"}
- If ($vNextPrids -Eq $null)
- {
- Write-Host "No registry keys found."
- Return
- }
- $vNextPrids | ForEach `
- {
- $mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_
- Switch ($mode)
- {
- 2 { $mode = "vNext"; Break }
- 3 { $mode = "Device"; Break }
- Default { $mode = "Legacy"; Break }
- }
- Write-Host $_ = $mode
- }
- }
- function PrintSharedComputerLicensing
- {
- $scaRegKey = "HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration"
- $scaValue = Get-ItemProperty -Path $scaRegKey -ErrorAction Ignore | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction Ignore
- $scaRegKey2 = "HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing"
- $scaValue2 = Get-ItemProperty -Path $scaRegKey2 -ErrorAction Ignore | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction Ignore
- $scaPolicyKey = "HKLM:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Licensing"
- $scaPolicyValue = Get-ItemProperty -Path $scaPolicyKey -ErrorAction Ignore | Select-Object -ExpandProperty "SharedComputerLicensing" -ErrorAction Ignore
- If ($scaValue -Eq $null -And $scaValue2 -Eq $null -And $scaPolicyValue -Eq $null)
- {
- Write-Host "No registry keys found."
- Return
- }
- $scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue
- If ($scaModeValue -Eq 0)
- {
- $scaMode = "Disabled"
- }
- If ($scaModeValue -Eq 1)
- {
- $scaMode = "Enabled"
- }
- Write-Host "SharedComputerLicensing" = $scaMode
- Write-Host
- $tokenFiles = $null
- $tokenPath = "${env:LOCALAPPDATA}\Microsoft\Office\16.0\Licensing"
- If (Test-Path $tokenPath)
- {
- $tokenFiles = Get-ChildItem -Path $tokenPath -Recurse -File -Filter "*authString*"
- }
- If ($tokenFiles.length -Eq 0)
- {
- Write-Host "No tokens found."
- Return
- }
- $tokenFiles | ForEach `
- {
- $tokenParts = (Get-Content -Encoding Unicode -Path $_.FullName).Split('_')
- $output = [PSCustomObject] `
- @{
- ACID = $tokenParts[0];
- User = $tokenParts[3]
- NotBefore = $tokenParts[4];
- NotAfter = $tokenParts[5];
- } | ConvertTo-Json
- Write-Host $output
- }
- }
- function PrintLicensesInformation
- {
- Param(
- [ValidateSet("NUL", "Device")]
- [String]$mode
- )
- If ($mode -Eq "NUL")
- {
- $licensePath = "${env:LOCALAPPDATA}\Microsoft\Office\Licenses"
- }
- ElseIf ($mode -Eq "Device")
- {
- $licensePath = "${env:PROGRAMDATA}\Microsoft\Office\Licenses"
- }
- $licenseFiles = $null
- If (Test-Path $licensePath)
- {
- $licenseFiles = Get-ChildItem -Path $licensePath -Recurse -File
- }
- If ($licenseFiles.length -Eq 0)
- {
- Write-Host "No licenses found."
- Return
- }
- $licenseFiles | ForEach `
- {
- $license = (Get-Content -Encoding Unicode $_.FullName | ConvertFrom-Json).License
- $decodedLicense = [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($license)) | ConvertFrom-Json
- $licenseType = $decodedLicense.LicenseType
- 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 ((Get-Date) -Lt (Get-Date $expiry))
- {
- $licenseState = "Licensed"
- }
- Else
- {
- $licenseState = "Grace"
- }
- if ($mode -Eq "NUL")
- {
- $output = [PSCustomObject] `
- @{
- Version = $_.Directory.Name
- Type = "User|${licenseType}";
- Product = $decodedLicense.ProductReleaseId;
- 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;
- TenantId = $decodedLicense.Metadata.TenantId;
- } | ConvertTo-Json
- }
- ElseIf ($mode -Eq "Device")
- {
- $output = [PSCustomObject] `
- @{
- Version = $_.Directory.Name
- Type = "Device|${licenseType}";
- Product = $decodedLicense.ProductReleaseId;
- Acid = $decodedLicense.Acid;
- 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;
- TenantId = $decodedLicense.Metadata.TenantId;
- } | ConvertTo-Json
- }
- Write-Output $output
- }
- }
- Write-Host
- Write-Host "========== Mode per ProductReleaseId =========="
- Write-Host
- PrintModePerPridFromRegistry
- Write-Host
- Write-Host "========== Shared Computer Licensing =========="
- Write-Host
- PrintSharedComputerLicensing
- Write-Host
- Write-Host "========== vNext licenses =========="
- Write-Host
- PrintLicensesInformation -Mode "NUL"
- Write-Host
- Write-Host "========== Device licenses =========="
- Write-Host
- PrintLicensesInformation -Mode "Device"
- :vNextDiag:
- ----- Begin wsf script --->
- <package>
- <job id="WmiQuery">
- <script language="VBScript">
- If WScript.Arguments.Count = 3 Then
- wExc = "Select " & WScript.Arguments.Item(2) & " from " & WScript.Arguments.Item(0) & " where " & WScript.Arguments.Item(1)
- wGet = WScript.Arguments.Item(2)
- Else
- wExc = "Select " & WScript.Arguments.Item(1) & " from " & WScript.Arguments.Item(0)
- wGet = WScript.Arguments.Item(1)
- End If
- Set objCol = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery(wExc,,48)
- For Each objItm in objCol
- For each Prop in objItm.Properties_
- If LCase(Prop.Name) = LCase(wGet) Then
- WScript.Echo Prop.Name & "=" & Prop.Value
- Exit For
- End If
- Next
- Next
- </script>
- </job>
- <job id="WmiMulti">
- <script language="VBScript">
- If WScript.Arguments.Count = 3 Then
- wExc = "Select " & WScript.Arguments.Item(2) & " from " & WScript.Arguments.Item(0) & " where " & WScript.Arguments.Item(1)
- Else
- wExc = "Select " & WScript.Arguments.Item(1) & " from " & WScript.Arguments.Item(0)
- End If
- Set objCol = GetObject("winmgmts:\\.\root\CIMV2").ExecQuery(wExc,,48)
- For Each objItm in objCol
- For each Prop in objItm.Properties_
- WScript.Echo Prop.Name & "=" & Prop.Value
- Next
- Next
- </script>
- </job>
- <job id="XPDT">
- <script language="VBScript">
- WScript.Echo DateAdd("n", WScript.Arguments.Item(0), Now)
- </script>
- </job>
- </package>
Add Comment
Please, Sign In to add comment