$os=Get-CimInstance Win32_OperatingSystem
$cur=Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
Write-Host "== CURRENT =="
Write-Host ("Edition: {0} | EditionID: {1} | Build {2}" -f $os.Caption,$cur.EditionID,$os.BuildNumber)
$lic=Get-CimInstance SoftwareLicensingProduct -Filter "ApplicationID='55c92734-d682-4d71-983e-d6ec3f16059f' AND PartialProductKey IS NOT NULL"
foreach($l in $lic){Write-Host ("Lic: {0} | Partial {1} | Status {2}(1=OK)" -f $l.Name,$l.PartialProductKey,$l.LicenseStatus)}
$oem=(Get-CimInstance SoftwareLicensingService).OA3xOriginalProductKey
Write-Host ("FirmwareKey: {0}" -f $(if($oem){$oem}else{"(none)"}))
Write-Host "== WINDOWS.OLD =="
$hive="C:\Windows.old\Windows\System32\config\SOFTWARE"
if(Test-Path $hive){
  reg load "HKLM\OLDSW" "$hive" | Out-Null
  try{
    $spp=Get-ItemProperty "HKLM:\OLDSW\Microsoft\Windows NT\CurrentVersion\SoftwareProtectionPlatform"
    $old=Get-ItemProperty "HKLM:\OLDSW\Microsoft\Windows NT\CurrentVersion"
    Write-Host ("BackupProductKeyDefault: {0}" -f $spp.BackupProductKeyDefault)
    Write-Host ("Old: {0} | EditionID {1}" -f $old.ProductName,$old.EditionID)
  }catch{Write-Host ("hive err: {0}" -f $_.Exception.Message)}
  finally{[gc]::Collect();Start-Sleep -Milliseconds 300;reg unload "HKLM\OLDSW" | Out-Null}
}else{Write-Host "no C:\Windows.old SOFTWARE hive"}
