2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								@ echo  off 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								: :  Check-Activation-Status  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								: :  Written by @abbodi1406  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								: :  https://gravesoft.dev/cas  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-08-18 01:38:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								: :  Set Environment variables, it helps if they are misconfigured in the system  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								setlocal  EnableExtensions 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								setlocal  DisableDelayedExpansion 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  " PathExt=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  " SysPath= %SystemRoot% \System32 "  
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								set  " Path= %SystemRoot% \System32; %SystemRoot% ; %SystemRoot% \System32\Wbem; %SystemRoot% \System32\WindowsPowerShell\v1.0\ "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  exist  " %SystemRoot% \Sysnative\reg.exe "  (  
						 
					
						
							
								
									
										
										
										
											2024-08-18 01:38:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								set  " SysPath= %SystemRoot% \Sysnative "  
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								set  " Path= %SystemRoot% \Sysnative; %SystemRoot% ; %SystemRoot% \Sysnative\Wbem; %SystemRoot% \Sysnative\WindowsPowerShell\v1.0\; %Path% "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
									
										
										
										
											2024-08-18 01:38:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  " ComSpec= %SysPath% \cmd.exe "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  " PSModulePath= %ProgramFiles% \WindowsPowerShell\Modules; %SysPath% \WindowsPowerShell\v1.0\Modules "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-20 16:05:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								set  " ps= %SysPath% \WindowsPowerShell\v1.0\powershell.exe "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  " _psc= %ps%  -nop -c "  
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								set  " _err===== ERROR ==== "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  _pwsh = 1 
						 
					
						
							
								
									
										
										
										
											2025-04-20 16:05:53 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  not  exist  %ps%  set  _pwsh = 0 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								cmd /c " %_psc%   " $ExecutionContext.SessionState.LanguageMode" "  |  find /i " FullLanguage "  1 > nul ||  ( set  _pwsh = 0) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if  %_pwsh%  equ  0 (  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								echo  %_err%  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								cmd /c " %_psc%   " $ExecutionContext.SessionState.LanguageMode" " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								echo  Windows PowerShell is not working correctly. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								echo  It is required for this script to work. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								goto  : E_Exit  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  " _batf= %~f0 "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								set  " _batp= %_batf:'=''% "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								setlocal  EnableDelayedExpansion 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								%_psc%  " $f=[IO.File]::ReadAllText('!_batp!') -split ':sppmgr\:.*';iex ($f[1]) "  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								: E_Exit  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								echo . 
						 
					
						
							
								
									
										
										
										
											2024-08-18 01:38:35 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								echo  Press 0 key to exit. 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								choice /c 0 /n
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								exit  /b 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								: sppmgr :  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								param (
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    [Parameter()]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    [switch]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $All,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    [Parameter()]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    [switch]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $Dlv,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    [Parameter()]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    [switch]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $IID,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    [Parameter()]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    [switch]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $Pass
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function CONOUT($strObj)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Out-Host -Input $strObj
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								function ExitScript($ExitCode = 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Exit  $ExitCode
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    $ P S V e r s i o n T a b l e )   {  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									" ==== ERROR ====`r`n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" Windows PowerShell 1.0 is not supported by this script. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									ExitScript 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - N E   0 )   {  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									" ==== ERROR ====`r`n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" Windows PowerShell is not running in Full Language Mode. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									ExitScript 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$winbuild = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								try {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$winbuild = [System.Diagnostics.FileVersionInfo]::GetVersionInfo(" $env:SystemRoot\System32\kernel32.dll " ).FileBuildPart
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								} catch {
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$winbuild = [int]([wmi]'Win32_OperatingSystem=@').BuildNumber
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - E Q   1 )   {  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									" ==== ERROR ====`r`n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" Could not detect Windows build. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									ExitScript 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - L T   2 6 0 0 )   {  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									" ==== ERROR ====`r`n " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" This build of Windows is not supported by this script. " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ExitScript 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if   
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$isAll = {CONOUT " `r " }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$noAll = {$null}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$isAll = {$null}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$noAll = {CONOUT " `r " }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$Dlv = $Dlv.IsPresent
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$IID = $IID.IsPresent -Or $Dlv.IsPresent
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								$NT6 = $winbuild -GE 6000
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$NT7 = $winbuild -GE 7600
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$NT8 = $winbuild -GE 9200
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								$NT9 = $winbuild -GE 9600
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$Admin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$line2 = " ============================================================ " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$line3 = " ____________________________________________________________ " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function echoWindows
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " $line2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " ===                   Windows Status                     === " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " $line2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									&  $noAll
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function echoOffice
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   0 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									&  $isAll
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " $line2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " ===                   Office Status                      === " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " $line2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									&  $noAll
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$script:doMSG = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function strGetRegistry($strKey, $strName)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									try {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return [Microsoft.Win32.Registry]::GetValue($strKey, $strName, $null)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} catch {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function CheckOhook
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$ohook = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$paths = " ${env:ProgramFiles} " , " ${env:ProgramW6432} " , " ${env:ProgramFiles(x86)} " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									15, 16 |  foreach `
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$A = $_; $paths |  foreach `
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if    " $ ( $ _ ) $ ( ' \ M i c r o s o f t   O f f i c e \ O f f i c e ' ) $ ( $ A ) $ ( ' \ s p p c * d l l ' ) " )   { $ o h o o k   =   1 } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" System " , " SystemX86 "  |  foreach `
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$A = $_; " Office 15 " , " Office "  |  foreach `
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$B = $_; $paths |  foreach `
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												if    " $ ( $ _ ) $ ( ' \ M i c r o s o f t   ' ) $ ( $ B ) $ ( ' \ r o o t \ v f s \ ' ) $ ( $ A ) $ ( ' \ s p p c * d l l ' ) " )   { $ o h o o k   =   1 } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   0 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									&  $isAll
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " $line2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " ===                Office Ohook Status                   === " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " $line2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$host.UI.WriteLine('Yellow', 'Black', " `r`nOhook for permanent Office activation is installed.`r`nYou can ignore the below mentioned Office activation status. " )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									&  $noAll
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#region SSSS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function BoolToWStr($bVal) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									( " TRUE " , " FALSE " ) [!$bVal]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function InitializePInvoke($LaDll, $bOffice) {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$LaName = [IO.Path]::GetFileNameWithoutExtension($LaDll)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$SLApp = $NT7 -Or $bOffice -Or ($LaName -EQ 'sppc' -And [Diagnostics.FileVersionInfo]::GetVersionInfo(" $SysPath\sppc.dll " ).FilePrivatePart -GE 16501)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Win32 = $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$Marshal = [System.Runtime.InteropServices.Marshal]
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$Module = [AppDomain]::CurrentDomain.DefineDynamicAssembly(($LaName+" _Assembly " ), 'Run').DefineDynamicModule(($LaName+" _Module " ), $False)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Class = $Module.DefineType(($LaName+" _Methods " ), 'Public, Abstract, Sealed, BeforeFieldInit', [Object], 0)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Class.DefinePInvokeMethod('SLClose', $LaDll, 22, 1, [Int32], @([IntPtr]), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Class.DefinePInvokeMethod('SLOpen', $LaDll, 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Class.DefinePInvokeMethod('SLGenerateOfflineInstallationId', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Class.DefinePInvokeMethod('SLGetSLIDList', $LaDll, 22, 1, [Int32], @([IntPtr], [UInt32], [Guid].MakeByRefType(), [UInt32], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Class.DefinePInvokeMethod('SLGetLicensingStatusInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [Guid].MakeByRefType(), [IntPtr], [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Class.DefinePInvokeMethod('SLGetPKeyInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Class.DefinePInvokeMethod('SLGetProductSkuInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Class.DefinePInvokeMethod('SLGetServiceInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Class.DefinePInvokeMethod('SLGetApplicationInformation', $LaDll, 22, 1, [Int32], @([IntPtr], [Guid].MakeByRefType(), [String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Win32 = $Class.CreateType()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Class.DefinePInvokeMethod('SLGetWindowsInformation', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Class.DefinePInvokeMethod('SLGetWindowsInformationDWORD', 'slc.dll', 22, 1, [Int32], @([String], [UInt32].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Class.DefinePInvokeMethod('SLIsGenuineLocal', 'slwga.dll', 22, 1, [Int32], @([Guid].MakeByRefType(), [UInt32].MakeByRefType(), [IntPtr]), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Class.DefinePInvokeMethod('SLIsWindowsGenuineLocal', 'slc.dll', 'Public, Static', 'Standard', [Int32], @([UInt32].MakeByRefType()), 'Winapi', 'Unicode').SetImplementationFlags('PreserveSig')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Class.DefinePInvokeMethod('ClipGetSubscriptionStatus', 'Clipc.dll', 22, 1, [Int32], @([IntPtr].MakeByRefType()), 1, 3).SetImplementationFlags(128)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Struct = $Class.DefineNestedType('SubStatus', 'NestedPublic, SequentialLayout, Sealed, BeforeFieldInit', [ValueType], 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[void]$Struct.DefineField('dwEnabled', [UInt32], 'Public')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[void]$Struct.DefineField('dwSku', [UInt32], 6)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[void]$Struct.DefineField('dwState', [UInt32], 6)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$SubStatus = $Struct.CreateType()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Win32 = $Class.CreateType()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function SlGetInfoIID($SkuId)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$bData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$hSLC,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref][Guid]$SkuId,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$bData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $Marshal::PtrToStringUni($bData)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function SlReturnData($hrRet, $tData, $cData, $bData) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - N E   0   - O r   $ c D a t a   - E Q   0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return $Marshal::PtrToStringUni($bData)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									elseif ($tData -EQ 4)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return $Marshal::ReadInt32($bData)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									elseif ($tData -EQ 3 -And $cData -EQ 8)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return $Marshal::ReadInt64($bData)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return $null
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function SlGetInfoPKey($PkeyId, $Value)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$tData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$cData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$bData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$hrRet = $Win32::SLGetPKeyInformation(
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$hSLC,
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										[ref][Guid]$PkeyId,
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$Value,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$tData,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$cData,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$bData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return SlReturnData $hrRet $tData $cData $bData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function SlGetInfoSku($SkuId, $Value)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$tData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$cData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$bData = 0
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$hrRet = $Win32::SLGetProductSkuInformation(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$hSLC,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref][Guid]$SkuId,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Value,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$tData,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$cData,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$bData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return SlReturnData $hrRet $tData $cData $bData
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function SlGetInfoApp($AppId, $Value)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$tData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$cData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$bData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$hrRet = $Win32::SLGetApplicationInformation(
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$hSLC,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref][Guid]$AppId,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Value,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$tData,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$cData,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$bData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return SlReturnData $hrRet $tData $cData $bData
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function SlGetInfoService($Value)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$tData = 0
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$cData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$bData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$hrRet = $Win32::SLGetServiceInformation(
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$hSLC,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Value,
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										[ref]$tData,
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										[ref]$cData,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$bData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return SlReturnData $hrRet $tData $cData $bData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function SlGetInfoSvcApp($strApp, $Value)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return SlGetInfoApp $strApp $Value
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return SlGetInfoService $Value
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function SlGetInfoLicensing($AppId, $SkuId)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$dwStatus = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$dwGrace = 0
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$hrReason = 0
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$qwValidity = 0
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$cStatus = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$pStatus = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$hrRet = $Win32::SLGetLicensingStatusInformation(
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$hSLC,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref][Guid]$AppId,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref][Guid]$SkuId,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										0,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$cStatus,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$pStatus
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - N E   0   - O r   $ c S t a t u s   - E Q   0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									[IntPtr]$ppStatus = [Int64]$pStatus + [Int64]40 * ($cStatus - 1)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$dwStatus = $Marshal::ReadInt32($ppStatus, 16)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$dwGrace = $Marshal::ReadInt32($ppStatus, 20)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$hrReason = $Marshal::ReadInt32($ppStatus, 28)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$qwValidity = $Marshal::ReadInt64($ppStatus, 32)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - E Q   3 ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$dwStatus = 5
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - E Q   2 ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    - E Q   0 x 4 0 0 4 F 0 0 D ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$dwStatus = 3
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										elseif ($hrReason -EQ 0x4004F065)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$dwStatus = 4
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										elseif ($hrReason -EQ 0x4004FC06)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$dwStatus = 6
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function SlGetInfoSLID($AppId)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$cReturnIds = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$pReturnIds = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$hrRet = $Win32::SLGetSLIDList(
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$hSLC,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										0,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref][Guid]$AppId,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										1,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$cReturnIds,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$pReturnIds
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - N E   0   - O r   $ c R e t u r n I d s   - E Q   0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$a1List = @()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$a2List = @()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$a3List = @()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$a4List = @()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									foreach ($i in 0..($cReturnIds - 1))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$bytes = New-Object byte[] 16
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Marshal::Copy([Int64]$pReturnIds + [Int64]16 * $i, $bytes, 0, 16)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$actid = ([Guid]$bytes).Guid
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$gPPK = SlGetInfoSku $actid " pkeyId " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$gAdd = SlGetInfoSku $actid " DependsOn " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if    - E Q   $ g P P K   - A n d   $ n u l l   - N E   $ g A d d )   {   $ a 1 L i s t   + =   @ { i d   =   $ a c t i d ;   p k   =   $ n u l l ;   e x   =   $ t r u e }   } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if    - E Q   $ g P P K   - A n d   $ n u l l   - E Q   $ g A d d )   {   $ a 2 L i s t   + =   @ { i d   =   $ a c t i d ;   p k   =   $ n u l l ;   e x   =   $ f a l s e }   } 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - N E   $ g P P K   - A n d   $ n u l l   - N E   $ g A d d )   {   $ a 3 L i s t   + =   @ { i d   =   $ a c t i d ;   p k   =   $ g P P K ;   e x   =   $ t r u e }   } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    - N E   $ g P P K   - A n d   $ n u l l   - E Q   $ g A d d )   {   $ a 4 L i s t   + =   @ { i d   =   $ a c t i d ;   p k   =   $ g P P K ;   e x   =   $ f a l s e }   } 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return ($a1List + $a2List + $a3List + $a4List)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function DetectSubscription {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									try
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$objSvc = New-Object PSObject
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$wmiSvc = [wmisearcher]" SELECT SubscriptionType, SubscriptionStatus, SubscriptionEdition, SubscriptionExpiry FROM SoftwareLicensingService " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$wmiSvc.Options.Rewindable = $false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$wmiSvc.Get() |  select -Expand Properties -EA 0 |  foreach { $objSvc |  Add-Member 8 $_.Name $_.Value }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$wmiSvc.Dispose()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									catch
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if    - E Q   $ o b j S v c . S u b s c r i p t i o n T y p e   - O r   $ o b j S v c . S u b s c r i p t i o n T y p e   - E Q   1 2 0 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   1 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$SubMsgType = " Device based " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$SubMsgType = " User based " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   1 2 0 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$SubMsgStatus = " Expired " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} elseif ($objSvc.SubscriptionStatus -EQ 100) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$SubMsgStatus = " Disabled " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} elseif ($objSvc.SubscriptionStatus -EQ 1) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$SubMsgStatus = " Active " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$SubMsgStatus = " Not active " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$SubMsgExpiry = " Unknown " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  " unspecified " )  - E Q   $ f a l s e )   { $ S u b M s g E x p i r y   =   $ o b j S v c . S u b s c r i p t i o n E x p i r y } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$SubMsgEdition = " Unknown " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if  " 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 } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `nSubscription information: " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Type   : $SubMsgType " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Status : $SubMsgStatus " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT "     Edition: $SubMsgEdition " 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT "     Expiry : $SubMsgExpiry " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function DetectAdbaClient
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$propADBA |  foreach { set $_ (SlGetInfoSku $licID $_) }
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `nAD Activation client information: " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Object Name: $ADActivationObjectName " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Domain Name: $ADActivationObjectDN " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT "     CSVLK Extended PID: $ADActivationCsvlkPID " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     CSVLK Activation ID: $ADActivationCsvlkSkuID " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function DetectAvmClient
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$propAVMA |  foreach { set $_ (SlGetInfoSku $licID $_) }
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `nAutomatic VM Activation client information: " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    [ S t r i n g ] : : I s N u l l O r E m p t y ( $ I n h e r i t e d A c t i v a t i o n I d ) )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT "     Guest IAID: $InheritedActivationId " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT "     Guest IAID: Not Available " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    [ S t r i n g ] : : I s N u l l O r E m p t y ( $ I n h e r i t e d 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: $InheritedActivationHostMachineName " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT "     Host machine name: Not Available " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    [ S t r i n g ] : : I s N u l l O r E m p t y ( $ I n h e r i t e d 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: $InheritedActivationHostDigitalPid2 " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT "     Host Digital PID2: Not Available " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$IAAT = [DateTime]::FromFileTime($InheritedActivationActivationTime).ToString('yyyy-MM-dd hh:mm:ss tt')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT "     Activation time: $IAAT " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT "     Activation time: Not Available " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function DetectKmsHost
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$IsKeyManagementService = SlGetInfoSvcApp $strApp 'IsKeyManagementService'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    $ I s K e y M a n a g e m e n t S e r v i c e )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if    - O r   $ N T 5 )   { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$regk = $SLKeyPath
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} elseif ($strSLP -EQ $oslp) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$regk = $OPKeyPath
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$regk = $SPKeyPath
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$KMSListening = strGetRegistry $regk " KeyManagementServiceListeningPort " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$KMSPublishing = strGetRegistry $regk " DisableDnsPublishing " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$KMSPriority = strGetRegistry $regk " EnableKmsLowPriority " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    $ K M S L i s t e n i n g )   { $ K M S L i s t e n i n g   =   1 6 8 8 } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    $ K M S P u b l i s h i n g )   { $ K M S P u b l i s h i n g   =   " T R U E " }   e l s e   { $ K M S P u b l i s h i n g   =   B o o l T o W S t r   ( ! $ K M S P u b l i s h i n g ) } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    $ K M S P r i o r i t y )   { $ K M S P r i o r i t y   =   " F A L S E " }   e l s e   { $ K M S P r i o r i t y   =   B o o l T o W S t r   $ K M S P r i o r i t y } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   " T R U E " )   { $ K M S P u b l i s h i n g   =   " E n a b l e d " }   e l s e   { $ K M S P u b l i s h i n g   =   " D i s a b l e d " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   " T R U E " )   { $ K M S P r i o r i t y   =   " L o w " }   e l s e   { $ K M S P r i o r i t y   =   " N o r m a l " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$propKMSServer |  foreach { set $_ (SlGetInfoApp $strApp $_) }
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$propKMSServer |  foreach { set $_ (SlGetInfoService $_) }
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$KMSRequests = $KeyManagementServiceTotalRequests
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$NoRequests = ($null -EQ $KMSRequests) -Or ($KMSRequests -EQ -1) -Or ($KMSRequests -EQ 4294967295)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `nKey Management Service host information: " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Current count: $KeyManagementServiceCurrentCount " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT "     Listening on Port: $KMSListening " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     DNS publishing: $KMSPublishing " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     KMS priority: $KMSPriority " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `nKey Management Service cumulative requests received from clients: " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Total: $KeyManagementServiceTotalRequests " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Failed: $KeyManagementServiceFailedRequests " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Unlicensed: $KeyManagementServiceUnlicensedRequests " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Licensed: $KeyManagementServiceLicensedRequests " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Initial grace period: $KeyManagementServiceOOBGraceRequests " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Expired or Hardware out of tolerance: $KeyManagementServiceOOTGraceRequests " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Non-genuine grace period: $KeyManagementServiceNonGenuineGraceRequests " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - 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 " } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function DetectKmsClient
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$VLType = strGetRegistry ($SPKeyPath + '\' + $strApp + '\' + $licID) " VLActivationType " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - E Q   $ V L T y p e )   { $ V L T y p e   =   s t r G e t R e g i s t r y   ( $ S P K e y P a t h   +   ' \ '   +   $ s t r A p p )   " V L A c t i v a t i o n T y p e " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    - E Q   $ V L T y p e )   { $ V L T y p e   =   s t r G e t R e g i s t r y   ( $ S P K e y P a t h )   " V L A c t i v a t i o n T y p e " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    - E Q   $ V L T y p e   - O r   $ V L T y p e   - G T   3 )   { $ V L T y p e   =   0 } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - N E   $ V L T y p e )   { 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 T y p e ] ) " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `r " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if    - N E   1 )   { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT " Please activate the product in order to update KMS client information values. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - O r   $ s t r S L P   - E Q   $ o s l p )   { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$propKMSClient |  foreach { set $_ (SlGetInfoSku $licID $_) }
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - E Q   $ o s l p )   { $ r e g k   =   $ O P K e y P a t h }   e l s e   { $ r e g k   =   $ S P K e y P a t h } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$KMSCaching = strGetRegistry $regk " DisableKeyManagementServiceHostCaching " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    $ K M S C a c h i n g )   { $ K M S C a c h i n g   =   " T R U E " }   e l s e   { $ K M S C a c h i n g   =   B o o l T o W S t r   ( ! $ K M S C a c h i n g ) } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" ClientMachineID "  |  foreach { set $_ (SlGetInfoService $_) }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$propKMSVista |  foreach { set $_ (SlGetInfoService $_) }
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$KeyManagementServicePort = strGetRegistry $SLKeyPath " KeyManagementServicePort " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$DiscoveredKeyManagementServiceName = strGetRegistry $NSKeyPath " DiscoveredKeyManagementServiceName " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$DiscoveredKeyManagementServicePort = strGetRegistry $NSKeyPath " DiscoveredKeyManagementServicePort " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$KmsReg = $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    $ K e y M a n a g e m e n t S e r v i c e P o r t )   { $ K e y M a n a g e m e n t S e r v i c e P o r t   =   1 6 8 8 } 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$KmsReg = " Registered KMS machine name: ${KeyManagementServiceName}:${KeyManagementServicePort} " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$KmsDns = " DNS auto-discovery: KMS name not available " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    - A n d   - N o t   $ A d m i n )   { $ K m s D n s   =   " D N S   a u t o - d i s c o v e r y :   R u n   t h e   s c r i p t   a s   a d m i n i s t r a t o r   t o   r e t r i e v e   i n f o " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    $ 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 P o r t )   { $ 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 P o r t   =   1 6 8 8 } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$KmsDns = " KMS machine name from DNS: ${DiscoveredKeyManagementServiceName}:${DiscoveredKeyManagementServicePort} " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - N E   $ K M S C a c h i n g )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    - E Q   " T R U E " )   { $ K M S C a c h i n g   =   " E n a b l e d " }   e l s e   { $ K M S C a c h i n g   =   " D i s a b l e d " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   $ w s l p   - A n d   $ N T 9 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$DiscoveredKeyManagementServiceIpAddress = " not available " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " Key Management Service client information: " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT "     Client Machine ID (CMID): $ClientMachineID " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if    - E Q   $ K m s R e g )   { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT "     $KmsDns " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT "     Registered KMS machine name: KMS name not available " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT "     $KmsReg " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - 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 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 I p A d d r e s s " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     KMS machine extended PID: $CustomerPID " 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT "     Activation interval: $VLActivationInterval minutes " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT "     Renewal interval: $VLRenewalInterval minutes " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - N E   $ K M S 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 M S C a c h i n g " } 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    [ 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 " } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function GetResult($strSLP, $strApp, $entry)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$licID = $entry.id
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$propPrd |  foreach { set $_ (SlGetInfoSku $licID $_) }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									. SlGetInfoLicensing $strApp $licID
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$LicenseStatus = $dwStatus
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$LicReason = $hrReason
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$EvaluationEndDate = $qwValidity
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$gprMnt = $dwGrace
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$pkid = $entry.pk
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$isPPK = $null -NE $pkid
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$add_on = $Name.IndexOf(" add-on for " , 5)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - N E   - 1 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$Name = $Name.Substring(0, $add_on + 7)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$licPHN = " empty " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - O r   $ A l l . I s P r e s e n t )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$licPHN = SlGetInfoSku $licID " msft:sl/EUL/PHONE/PUBLIC " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   0   - A n d   ! $ i s P P K )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										&  $isAll
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT " Name: $Name " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT " Description: $Description " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT " Activation ID: $licID " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT " License Status: Unlicensed " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    - N E   " e m p t y " )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											CONOUT " Phone activatable: $($gPHN.ToString()) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$winID = ($strApp -EQ $winApp)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$winPR = ($winID -And -Not $entry.ex)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									$Vista = ($winID -And $NT6 -And -Not $NT7)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$NT5 = ($strSLP -EQ $wslp -And $winbuild -LT 6001)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$win8 = ($strSLP -EQ $wslp -And $NT8)
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$reapp = (" Windows " , " App " )[!$winID]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$prmnt = (" machine " , " product " )[!$winPR]
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  " VOLUME_KMSCLIENT " ))  { $ c K m s C l i e n t   =   1 ;   $ a c t T a g   =   " V o l u m e " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  " TIMEBASED_ " ))  { $ c T b l C l i e n t   =   1 ;   $ a c t T a g   =   " T i m e b a s e d " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  " VIRTUAL_MACHINE_ACTIVATION " ))  { $ c A v m C l i e n t   =   1 ;   $ a c t T a g   =   " A u t o m a t i c   V M " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   $ c K m s C l i e n t   - A n d   $ D e s c r i p t i o n . C o n t a i n s ( " V O L U M E _ K M S " ) )   { $ c K m s S e r v e r   =   1 } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$gprDay = [Math]::Round($gprMnt/1440)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$_xpr = " " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$inGrace = $false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - G T   0 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$_xpr = [DateTime]::Now.AddMinutes($gprMnt).ToString('yyyy-MM-dd hh:mm:ss tt')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$inGrace = $true
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$LicenseMsg = " Time remaining: $gprMnt minute(s) ($gprDay day(s)) " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									if    - E Q   0 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$LicenseInf = " Unlicensed " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$LicenseMsg = $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   1 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$LicenseInf = " Licensed " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - E Q   0 )   { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$LicenseMsg = $null
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$ExpireMsg = " The $prmnt is permanently activated. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$LicenseMsg = " $actTag activation expiration: $gprMnt minute(s) ($gprDay day(s)) " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											if    { $ E x p i r e M s g   =   " $ a c t 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 " } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   2 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$LicenseInf = " Initial grace period " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    { $ E x p i r e M s g   =   " $ L i c e n s e I n f   e n d s   $ _ x p r " } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   3 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$LicenseInf = " Additional grace period (KMS license expired or hardware out of tolerance) " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    { $ E x p i r e M s g   =   " A d d i t i o n a l   g r a c e   p e r i o d   e n d s   $ _ x p r " } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   4 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$LicenseInf = " Non-genuine grace period " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    { $ E x p i r e M s g   =   " $ L i c e n s e I n f   e n d s   $ _ x p r " } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   5   - A n d   - N o t   $ N T 5 )   { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$LicenseReason = '0x{0:X}' -f $LicReason
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										$LicenseInf = " Notification " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$LicenseMsg = " Notification Reason: $LicenseReason " 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - 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 ) . " } } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										if    - 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 ) . " } 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - 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 ) . " } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - 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 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$LicenseMsg = $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   6   - A n d   - N o t   $ V i s t a   - A n d   - N o t   $ N T 5 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$LicenseInf = " Extended grace period " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    { $ E x p i r e M s g   =   " $ L i c e n s e I n f   e n d s   $ _ x p r " } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$propPkey |  foreach { set $_ (SlGetInfoPKey $pkid $_) }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - A n d   $ i s P P K   - A n d   - N o t   $ N T 8 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$uxd = SlGetInfoSku $licID 'UXDifferentiator'
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$script:primary += @{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											aid = $licID;
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											ppk = $PartialProductKey;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											chn = $Channel;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											lst = $LicenseStatus;
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											lcr = $LicReason;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											ged = $gprMnt;
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											evl = $EvaluationEndDate;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											dff = $uxd
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - A n d   $ i s P P K )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$OfflineInstallationId = SlGetInfoIID $licID
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if  
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$RemainingSkuReArmCount = SlGetInfoSku $licID 'RemainingRearmCount'
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											$RemainingAppReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount'
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										else
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											if    - A n d   $ N T 7 )   - O r   $ s t r S L P   - E Q   $ o s l p ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$RemainingSLReArmCount = SlGetInfoApp $strApp 'RemainingRearmCount'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
												$RemainingSLReArmCount = SlGetInfoService 'RearmCount'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											}
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - E Q   $ T r u s t e d T i m e ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$TrustedTime = SlGetInfoSvcApp $strApp 'TrustedTime'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									&  $isAll
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " Name: $Name " 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " Description: $Description " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " Activation ID: $licID " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - N E   $ D i g i t a l P I D )   { C O N O U T   " E x t e n d e d   P I D :   $ D i g i t a l P I D " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - N E   $ D i g i t a l P I D 2   - A n d   $ D l v )   { C O N O U T   " P r o d u c t   I D :   $ D i g i t a l P I D 2 " } 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - 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 " } 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - N E   $ 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 :   $ C h a n n e l " } 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - 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    - 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 " } 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - N E   0   - A n d   $ E v a l u a t i o n E n d D a t e )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$EED = [DateTime]::FromFileTimeUtc($EvaluationEndDate).ToString('yyyy-MM-dd hh:mm:ss tt')
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT " Evaluation End Date: $EED UTC " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - N E   1   - A n d   $ l i c P H N   - N E   " e m p t y " )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$gPHN = [String]::IsNullOrEmpty($licPHN) -NE $true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT " Phone activatable: $($gPHN.ToString()) " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - N E   $ R e m a i n i n g S L R e A r m C o u n t )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											CONOUT " Remaining $reapp rearm count: $RemainingSLReArmCount " 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - N E   $ R e m a i n i n g S k u R e A r m C o u n t )   { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											CONOUT " Remaining $reapp rearm count: $RemainingAppReArmCount " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											CONOUT " Remaining SKU rearm count: $RemainingSkuReArmCount " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - N E   0   - A n d   $ T r u s t e d T i m e )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$TTD = [DateTime]::FromFileTime($TrustedTime).ToString('yyyy-MM-dd hh:mm:ss tt')
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
											CONOUT " Trusted time: $TTD " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - A n d   $ V L A c t i v a t i o n T y p e   - E Q   1 )   { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										DetectAdbaClient
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - A n d   $ n u l l   - N E   $ c A v m C l i e n t )   { 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										DetectAvmClient
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$chkSub = ($winPR -And $isSub)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$chkSLS = ($null -NE $cKmsClient -Or $null -NE $cKmsServer -Or $chkSub)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - 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 " } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - N E   $ c K m s C l i e n t )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										DetectKmsClient
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - N E   $ c K m s S e r v e r )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    - 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
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										if    - 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 " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										DetectSubscription
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function ParseList($strSLP, $strApp, $arrList)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									foreach ($entry in $arrList)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										GetResult $strSLP $strApp $entry
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT " $line3 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										&  $noAll
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								#endregion
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#region vNextDiag
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - L t   3 )  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function ConvertFrom-Json
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[CmdletBinding()]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Param(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											[Parameter(ValueFromPipeline=$true)][Object]$item
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[void][System.Reflection.Assembly]::LoadWithPartialName(" System.Web.Extensions " )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$psjs = New-Object System.Web.Script.Serialization.JavaScriptSerializer
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Return ,$psjs.DeserializeObject($item)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									function ConvertTo-Json
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[CmdletBinding()]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Param(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											[Parameter(ValueFromPipeline=$true)][Object]$item
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[void][System.Reflection.Assembly]::LoadWithPartialName(" System.Web.Extensions " )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$psjs = New-Object System.Web.Script.Serialization.JavaScriptSerializer
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Return $psjs.Serialize($item)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function PrintModePerPridFromRegistry
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$vNextRegkey = " HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$vNextPrids = Get-Item -Path $vNextRegkey -ErrorAction SilentlyContinue |  Select-Object -ExpandProperty 'property' -ErrorAction SilentlyContinue |  Where-Object -FilterScript {$_.ToLower() -like " *retail "  -or $_.ToLower() -like " *volume " }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									If    - E q   $ v N e x t P r i d s ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT " `nNo registry keys found. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										Return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `r " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									$vNextPrids |  ForEach `
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$mode = (Get-ItemProperty -Path $vNextRegkey -Name $_).$_
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Switch ($mode)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											2 { $mode = " vNext " ; Break }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											3 { $mode = " Device " ; Break }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											Default { $mode = " Legacy " ; Break }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT " $_ = $mode " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function PrintSharedComputerLicensing
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$scaRegKey = " HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$scaValue = Get-ItemProperty -Path $scaRegKey -ErrorAction SilentlyContinue |  Select-Object -ExpandProperty " SharedComputerLicensing "  -ErrorAction SilentlyContinue
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$scaRegKey2 = " HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$scaValue2 = Get-ItemProperty -Path $scaRegKey2 -ErrorAction SilentlyContinue |  Select-Object -ExpandProperty " SharedComputerLicensing "  -ErrorAction SilentlyContinue
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$scaPolicyKey = " HKLM:\SOFTWARE\Policies\Microsoft\Office\16.0\Common\Licensing " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$scaPolicyValue = Get-ItemProperty -Path $scaPolicyKey -ErrorAction SilentlyContinue |  Select-Object -ExpandProperty " SharedComputerLicensing "  -ErrorAction SilentlyContinue
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									If    - 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 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT " `nNo registry keys found. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										Return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$scaModeValue = $scaValue -Or $scaValue2 -Or $scaPolicyValue
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									If    - E q   0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$scaMode = " Disabled " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									If    - E q   1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$scaMode = " Enabled " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `nStatus: $scaMode " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " `r " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									$tokenFiles = $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$tokenPath = " ${env:LOCALAPPDATA}\Microsoft\Office\16.0\Licensing " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									If    $ t o k e n P a t h ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$tokenFiles = Get-ChildItem -Path $tokenPath -Filter " *authString* "  -Recurse |  Where-Object { !$_.PSIsContainer }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-02-03 19:27:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									If    - E q   $ t o k e n F i l e s   - O r   $ t o k e n F i l e s . L e n g t h   - E q   0 ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT " No tokens found. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										Return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$tokenFiles |  ForEach `
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$tokenParts = (Get-Content -Encoding Unicode -Path $_.FullName).Split('_')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output = New-Object PSObject
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'ACID' $tokenParts[0];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'User' $tokenParts[3];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'NotBefore' $tokenParts[4];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'NotAfter' $tokenParts[5];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Write-Output $output
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function PrintLicensesInformation
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									Param(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ValidateSet(" NUL " , " Device " )]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[String]$mode
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									If    - E q   " N U L " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$licensePath = " ${env:LOCALAPPDATA}\Microsoft\Office\Licenses " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ElseIf ($mode -Eq " Device " )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$licensePath = " ${env:PROGRAMDATA}\Microsoft\Office\Licenses " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$licenseFiles = $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									If    $ l i c e n s e P a t h ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$licenseFiles = Get-ChildItem -Path $licensePath -Recurse |  Where-Object { !$_.PSIsContainer }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									If    - 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 ) 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT " `nNo licenses found. " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
										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    - N e   $ d e c o d e d L i c e n s e . E x p i r e s O n ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$expiry = [System.DateTime]::Parse($decodedLicense.ExpiresOn, $null, 'AdjustToUniversal')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$expiry = New-Object System.DateTime
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$licenseState = " Grace " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										If    - G t   ( G e t - D a t e   $ d e c o d e d L i c e n s e . M e t a d a t a . N o t A f t e r ) ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$licenseState = " RFM " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										ElseIf ((Get-Date) -Lt (Get-Date $expiry))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
											$licenseState = " Licensed " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output = New-Object PSObject
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'File' $_.PSChildName;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'Version' $_.Directory.Name;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'Type' " User|${licenseType} " ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'Product' $decodedLicense.ProductReleaseId;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'Acid' $decodedLicense.Acid;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										If    - E q   " D e v i c e " )   {   $ o u t p u t   |   A d d - M e m b e r   8   ' D e v i c e I d '   $ d e c o d e d L i c e n s e . M e t a d a t a . D e v i c e I d ;   } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'LicenseState' $licenseState;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'EntitlementStatus' $decodedLicense.Status;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'EntitlementExpiration' (" N/A " , $decodedLicense.ExpiresOn)[!($null -eq $decodedLicense.ExpiresOn)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'ReasonCode' (" N/A " , $decodedLicense.ReasonCode)[!($null -eq $decodedLicense.ReasonCode)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'NotBefore' $decodedLicense.Metadata.NotBefore;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'NotAfter' $decodedLicense.Metadata.NotAfter;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'NextRenewal' $decodedLicense.Metadata.RenewAfter;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$output |  Add-Member 8 'TenantId' (" N/A " , $decodedLicense.Metadata.TenantId)[!($null -eq $decodedLicense.Metadata.TenantId)];
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										#$output.PSObject.Properties |  foreach { $ht = @{} } { $ht[$_.Name] = $_.Value } { $output = $ht |  ConvertTo-Json }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Write-Output $output
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function vNextDiagRun
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-05-06 14:39:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$fNUL = ([IO.Directory]::Exists(" ${env:LOCALAPPDATA}\Microsoft\Office\Licenses " )) -and ([IO.Directory]::GetFiles(" ${env:LOCALAPPDATA}\Microsoft\Office\Licenses " , " * " , 1).Length -GT 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$fDev = ([IO.Directory]::Exists(" ${env:PROGRAMDATA}\Microsoft\Office\Licenses " )) -and ([IO.Directory]::GetFiles(" ${env:PROGRAMDATA}\Microsoft\Office\Licenses " , " * " , 1).Length -GT 0)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									$rPID = $null -NE (GP " HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing\LicensingNext "  -EA 0 |  select -Expand 'property' -EA 0 |  where -Filter {$_.ToLower() -like " *retail "  -or $_.ToLower() -like " *volume " })
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$rSCA = $null -NE (GP " HKLM:\SOFTWARE\Microsoft\Office\ClickToRun\Configuration "  -EA 0 |  select -Expand " SharedComputerLicensing "  -EA 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$rSCL = $null -NE (GP " HKLM:\SOFTWARE\Microsoft\Office\16.0\Common\Licensing "  -EA 0 |  select -Expand " SharedComputerLicensing "  -EA 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - O r   $ f D e v   - O r   $ r P I D   - O r   $ r S C A   - O r   $ r S C L )   - E Q   $ f a l s e )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										Return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									&  $isAll
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " $line2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " ===                  Office vNext Status                 === " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " $line2 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " `n========== Mode per ProductReleaseId ========== " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									PrintModePerPridFromRegistry
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `n========== Shared Computer Licensing ========== " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									PrintSharedComputerLicensing
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `n========== vNext licenses =========== " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									PrintLicensesInformation -Mode " NUL " 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " `n========== Device licenses ========== " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									PrintLicensesInformation -Mode " Device " 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " $line3 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " `r " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#endregion
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#region clic
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								< # 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								;;; Source: https://github.com/asdcorp/clic
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								;;; Powershell port: abbodi1406
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Copyright 2023 asdcorp
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								Permission is hereby granted, free of charge, to any person obtaining a copy of
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								this software and associated documentation files (the " Software " ), to deal in
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the Software without restriction, including without limitation the rights to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								the Software, and to permit persons to whom the Software is furnished to do so,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								subject to the following conditions:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								The above copyright notice and this permission notice shall be included in all
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								copies or substantial portions of the Software.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								THE SOFTWARE IS PROVIDED " AS IS " , WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								FOR  A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function InitializeDigitalLicenseCheck {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$CAB = [System.Reflection.Emit.CustomAttributeBuilder]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$ICom = $Module.DefineType('EUM.IEUM', 'Public, Interface, Abstract, Import')
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$ICom.SetCustomAttribute($CAB::new([System.Runtime.InteropServices.ComImportAttribute].GetConstructor(@()), @()))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$ICom.SetCustomAttribute($CAB::new([System.Runtime.InteropServices.GuidAttribute].GetConstructor(@([String])), @('F2DCB80D-0670-44BC-9002-CD18688730AF')))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$ICom.SetCustomAttribute($CAB::new([System.Runtime.InteropServices.InterfaceTypeAttribute].GetConstructor(@([Int16])), @([Int16]1)))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									1..4 |  % { [void]$ICom.DefineMethod('VF'+$_, 'Public, Virtual, HideBySig, NewSlot, Abstract', 'Standard, HasThis', [Void], @()) }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									[void]$ICom.DefineMethod('AcquireModernLicenseForWindows', 1478, 33, [Int32], @([Int32], [Int32].MakeByRefType()))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$IEUM = $ICom.CreateType()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function PrintStateData {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$pwszStateData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$cbSize = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" Security-SPP-Action-StateData " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$null,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$cbSize,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$pwszStateData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $FALSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									[string[]]$pwszStateString = $Marshal::PtrToStringUni($pwszStateData) -replace " ; " , " `n     " 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT ("     $pwszStateString " )
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Marshal::FreeHGlobal($pwszStateData)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return $TRUE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function PrintLastActivationHResult {
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									$pdwLastHResult = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$cbSize = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" Security-SPP-LastWindowsActivationHResult " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$null,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$cbSize,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$pdwLastHResult
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $FALSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT ("     LastActivationHResult=0x{0:x8} "  -f $Marshal::ReadInt32($pdwLastHResult))
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Marshal::FreeHGlobal($pdwLastHResult)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return $TRUE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								function PrintLastActivationTime {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$pqwLastTime = 0
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$cbSize = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										" Security-SPP-LastWindowsActivationTime " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$null,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$cbSize,
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										[ref]$pqwLastTime
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									)) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $FALSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$actTime = $Marshal::ReadInt64($pqwLastTime)
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - n e   0 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										CONOUT ("     LastActivationTime={0} "  -f [DateTime]::FromFileTimeUtc($actTime).ToString(" yyyy/MM/dd:HH:mm:ss " ))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$Marshal::FreeHGlobal($pqwLastTime)
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return $TRUE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								function PrintIsWindowsGenuine {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$dwGenuine = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $FALSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - l t   5 )   { 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT ("     IsWindowsGenuine={0} "  -f $ppwszGenuineStates[$dwGenuine])
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										CONOUT ("     IsWindowsGenuine={0} "  -f $dwGenuine)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return $TRUE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function PrintDigitalLicenseStatus {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									try {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										. InitializeDigitalLicenseCheck
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$ComObj = New-Object -Com EditionUpgradeManagerObj.EditionUpgradeManager
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} catch {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $FALSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$parameters = 1, $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  " AcquireModernLicenseForWindows " ).Invoke($ComObj,   $ p a r a m e t e r s ) )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $FALSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$dwReturnCode = $parameters[1]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									[bool]$bDigitalLicense = $FALSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$bDigitalLicense = (($dwReturnCode -ge 0) -and ($dwReturnCode -ne 1))
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT ("     IsDigitalLicense={0} "  -f (BoolToWStr $bDigitalLicense))
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return $TRUE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function PrintSubscriptionStatus {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$dwSupported = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - g e   1 5 0 6 3 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$pwszPolicy = " ConsumeAddonPolicySet " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$pwszPolicy = " Allow-WindowsSubscription " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if  ,   [ r e f ] $ d w S u p p o r t e d ) )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $FALSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT ("     SubscriptionSupportedEdition={0} "  -f (BoolToWStr $dwSupported))
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$pStatus = $Marshal::AllocHGlobal($Marshal::SizeOf([Type]$SubStatus))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $FALSE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$sStatus = [Activator]::CreateInstance($SubStatus)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$sStatus = $Marshal::PtrToStructure($pStatus, [Type]$SubStatus)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$Marshal::FreeHGlobal($pStatus)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT ("     SubscriptionEnabled={0} "  -f (BoolToWStr $sStatus.dwEnabled))
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - e q   0 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $TRUE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT ("     SubscriptionSku={0} "  -f $sStatus.dwSku)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT ("     SubscriptionState={0} "  -f $sStatus.dwState)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return $TRUE
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function ClicRun
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									&  $isAll
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " Client Licensing Check information: " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$null = PrintStateData
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$null = PrintLastActivationHResult
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$null = PrintLastActivationTime
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									$null = PrintIsWindowsGenuine
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$null = PrintDigitalLicenseStatus
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$null = PrintSubscriptionStatus
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " $line3 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									&  $noAll
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#endregion
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								#region clc
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function clcGetExpireKrn
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$tData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$cData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$bData = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$hrRet = $Win32::SLGetWindowsInformation(
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										" Kernel-ExpirationDate " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$tData,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$cData,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										[ref]$bData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if    - O r   ! $ c D a t a   - O r   $ t D a t a   - N E   3 ) 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$year = $Marshal::ReadInt16($bData, 0)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   0   - O r   $ y e a r   - E Q   1 6 0 1 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$rData = $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									else
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$rData = '{0}/{1}/{2}:{3}:{4}:{5}' -f $year, $Marshal::ReadInt16($bData, 2), $Marshal::ReadInt16($bData, 4), $Marshal::ReadInt16($bData, 6), $Marshal::ReadInt16($bData, 8), $Marshal::ReadInt16($bData, 10)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									#$Marshal::FreeHGlobal($bData)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return $rData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function clcGetExpireSys
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$kuser = $Marshal::ReadInt64((New-Object IntPtr(0x7FFE02C8)))
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   0 ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return $null
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-05-06 14:39:33 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$rData = [DateTime]::FromFileTimeUtc($kuser).ToString('yyyy/MM/dd:HH:mm:ss')
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									return $rData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function clcGetLicensingState($dwState)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   5 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$dwState = 3
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} elseif ($dwState -EQ 3 -Or $dwState -EQ 4 -Or $dwState -EQ 6) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$dwState = 2
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} elseif ($dwState -GT 6) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$dwState = 4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$rData = '{0}' -f $ppwszLicensingStates[$dwState]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return $rData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function clcGetGenuineState($AppId)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$dwGenuine = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$hrRet = $Win32::SLIsWindowsGenuineLocal([ref]$dwGenuine)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
										$hrRet = $Win32::SLIsGenuineLocal([ref][Guid]$AppId, [ref]$dwGenuine, 0)
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									if  
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$dwGenuine = 4
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - L T   5 )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$rData = '{0}' -f $ppwszGenuineStates[$dwGenuine]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$rData = $dwGenuine
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									return $rData
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								function ClcRun
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$prs = $script:primary[0]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - E Q   $ p r s )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										return
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$lState = clcGetLicensingState $prs.lst
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$uState = clcGetGenuineState $winApp
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$TbbKrn = clcGetExpireKrn
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$TbbSys = clcGetExpireSys
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - N E   $ T b b K r n )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$ked = $TbbKrn
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} elseif ($null -NE $TbbSys) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										$ked = $TbbSys
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									&  $isAll
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " Client Licensing Check information: " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT ("     AppId={0} "  -f $winApp)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    {   C O N O U T   ( "         G r a c e E n d D a t e = { 0 } "   - f   ( [ D a t e T i m e ] : : U t c N o w . A d d M i n u t e s ( $ p r s . g e d ) . T o S t r i n g ( ' y y y y / M M / d d : H H : m m : s s ' ) ) )   } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - N E   $ k e d )   {   C O N O U T   ( "         K e r n e l T i m e b o m b D a t e = { 0 } "   - f   $ k e d )   } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT ("     LastConsumptionReason=0x{0:x8} "  -f $prs.lcr)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    {   C O N O U T   ( "         L i c e n s e E x p i r a t i o n D a t e = { 0 } "   - f   ( [ D a t e T i m e ] : : F r o m F i l e T i m e U t c ( $ p r s . e v l ) . T o S t r i n g ( ' y y y y / M M / d d : H H : m m : s s ' ) ) )   } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT ("     LicenseState={0} "  -f $lState)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT ("     PartialProductKey={0} "  -f $prs.ppk)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT ("     ProductKeyType={0} "  -f $prs.chn)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT ("     SkuId={0} "  -f $prs.aid)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT ("     uxDifferentiator={0} "  -f $prs.dff)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT ("     IsWindowsGenuine={0} "  -f $uState)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									CONOUT " $line3 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									&  $noAll
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#endregion
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								$Host.UI.RawUI.WindowTitle = " Check Activation Status " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    {  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$B=$Host.UI.RawUI.BufferSize;$B.Height=3000;$Host.UI.RawUI.BufferSize=$B;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    { c l e a r ; } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-02-03 19:27:37 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$SysPath = " $env:SystemRoot\System32 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    " $ 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 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								$wslp = " SoftwareLicensingProduct " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$wsls = " SoftwareLicensingService " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$oslp = " OfficeSoftwareProtectionProduct " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$osls = " OfficeSoftwareProtectionService " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$winApp = " 55c92734-d682-4d71-983e-d6ec3f16059f " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$o14App = " 59a52881-a989-479d-af46-f275c6370663 " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$o15App = " 0ff1ce15-a989-479d-af46-f275c6370663 " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-29 19:10:56 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$isSub = ($winbuild -GE 26000) -And (Select-String -Path " $SysPath\wbem\sppwmi.mof "  -Encoding unicode -Pattern " SubscriptionType " )
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								$DllDigital = ($winbuild -GE 14393) -And (Test-Path " $SysPath\EditionUpgradeManagerObj.dll " )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$DllSubscription = ($winbuild -GE 14393) -And (Test-Path " $SysPath\Clipc.dll " )
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$VLActTypes = @(" All " , " AD " , " KMS " , " Token " )
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$OPKeyPath = " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OfficeSoftwareProtectionPlatform " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$SPKeyPath = " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform " 
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$SLKeyPath = " HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$NSKeyPath = " HKEY_USERS\S-1-5-20\SOFTWARE\Microsoft\Windows NT\CurrentVersion\SL " 
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$propPrd = 'Name', 'Description', 'TrustedTime', 'VLActivationType'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$propPkey = 'PartialProductKey', 'Channel', 'DigitalPID', 'DigitalPID2'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$propKMSServer = 'KeyManagementServiceCurrentCount', 'KeyManagementServiceTotalRequests', 'KeyManagementServiceFailedRequests', 'KeyManagementServiceUnlicensedRequests', 'KeyManagementServiceLicensedRequests', 'KeyManagementServiceOOBGraceRequests', 'KeyManagementServiceOOTGraceRequests', 'KeyManagementServiceNonGenuineGraceRequests', 'KeyManagementServiceNotificationRequests'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$propKMSClient = 'CustomerPID', 'KeyManagementServiceName', 'KeyManagementServicePort', 'DiscoveredKeyManagementServiceName', 'DiscoveredKeyManagementServicePort', 'DiscoveredKeyManagementServiceIpAddress', 'VLActivationInterval', 'VLRenewalInterval', 'KeyManagementServiceLookupDomain'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$propKMSVista  = 'CustomerPID', 'KeyManagementServiceName', 'VLActivationInterval', 'VLRenewalInterval'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$propADBA = 'ADActivationObjectName', 'ADActivationObjectDN', 'ADActivationCsvlkPID', 'ADActivationCsvlkSkuID'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$propAVMA = 'InheritedActivationId', 'InheritedActivationHostMachineName', 'InheritedActivationHostDigitalPid2', 'InheritedActivationActivationTime'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$primary = @()
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$ppwszGenuineStates = @(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_GEN_STATE_IS_GENUINE " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_GEN_STATE_INVALID_LICENSE " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_GEN_STATE_TAMPERED " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_GEN_STATE_OFFLINE " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_GEN_STATE_LAST " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$ppwszLicensingStates = @(
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_LICENSING_STATUS_UNLICENSED " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_LICENSING_STATUS_LICENSED " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_LICENSING_STATUS_IN_GRACE_PERIOD " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_LICENSING_STATUS_NOTIFICATION " ,
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									" SL_LICENSING_STATUS_LAST " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								)  
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								'cW1nd0ws', 'c0ff1ce15', 'c0ff1ce14', 'ospp14', 'ospp15' |  foreach {set $_ @()}
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$offsvc = " osppsvc " 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - 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 " }  
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								try {gsv $winsvc -EA 1 |  Out-Null; $WsppHook = 1} catch {$WsppHook = 0}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								try {gsv $offsvc -EA 1 |  Out-Null; $OsppHook = 1} catch {$OsppHook = 0}
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if    " $ 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 {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$WsppHook = 0
							 
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - N E   0 )   {  
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									$OLdll = (strGetRegistry $OPKeyPath " Path " ) + 'osppc.dll'
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    " $ O L d l l " ) )   { $ O s p p H o o k   =   0 } 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if    - N E   0 )   {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									if    - A n d   - N o t   $ N T 7   - A n d   - N o t   $ A d m i n )   { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										if    - E Q   [ D i a g n o s t i c s . P r o c e s s ] : : G e t P r o c e s s e s B y N a m e ( " $ w i n s v c " ) [ 0 ] . P r o c e s s N a m e )   { $ W s p p H o o k   =   0 ;   C O N O U T   " ` n E r r o r :   f a i l e d   t o   s t a r t   $ w i n s v c   S e r v i c e . ` n " } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									} else {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
										try {sasv $winsvc -EA 1} catch {$WsppHook = 0; CONOUT " `nError: failed to start $winsvc Service.`n " }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - N E   0 )   {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									. InitializePInvoke $SLdll $false
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$hSLC = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									[void]$Win32::SLOpen([ref]$hSLC)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$cW1nd0ws  = SlGetInfoSLID $winApp
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$c0ff1ce15 = SlGetInfoSLID $o15App
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$c0ff1ce14 = SlGetInfoSLID $o14App
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - G T   0 )  
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									echoWindows
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ParseList $wslp $winApp $cW1nd0ws
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								elseif ($NT6)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									echoWindows
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CONOUT " Error: product key not found.`n " 
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if    - A n d   - N o t   $ N T 8 )   {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClcRun
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if    {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									ClicRun
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								$doMSG = 1
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if    - G T   0 )  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									CheckOhook
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									echoOffice
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ParseList $wslp $o15App $c0ff1ce15
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if    - G T   0 )  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									echoOffice
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ParseList $wslp $o14App $c0ff1ce14
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									[void]$Win32::SLClose($hSLC)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if    - N E   0 )   {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									try {sasv $offsvc -EA 1} catch {$OsppHook = 0; CONOUT " `nError: failed to start $offsvc Service.`n " }
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - N E   0 )   {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									. InitializePInvoke " $OLdll "  $true
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$hSLC = 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									[void]$Win32::SLOpen([ref]$hSLC)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$ospp15 = SlGetInfoSLID $o15App
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									$ospp14 = SlGetInfoSLID $o14App
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    - G T   0 )  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									echoOffice
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ParseList $oslp $o15App $ospp15
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if    - G T   0 )  
						 
					
						
							
								
									
										
										
										
											2025-01-29 21:55:04 +01:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
									echoOffice
							 
						 
					
						
							
								
									
										
										
										
											2025-04-16 00:17:15 +02:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
									ParseList $oslp $o14App $ospp14
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									[void]$Win32::SLClose($hSLC)
							 
						 
					
						
							
								
									
										
										
										
											2024-07-13 01:16:38 +02:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								if    {  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
									vNextDiagRun
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								ExitScript 0
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								: sppmgr :