# Function to get WinRE path
function GetWinREPath { $WinRELocation = (reagentc /info | Select-String "Windows RE location") if ($WinRELocation) { return $WinRELocation.ToString.Split(':')[-1].Trim } else { Write-Host "Failed to find WinRE path" -ForegroundColor Red exit 1 }
} # Function to get WinRE version
function GetWinREVersion { $mountedPath = "$env:SystemDrive\mnt" if (-not (Test-Path $mountedPath) { New-Item -ItemType Directory -Path $mountedPath -Force | Out-Null } dism /Mount-Image /ImageFile:"$WinREPath\winre.wim" /Index:1 /MountDir:"$mountedPath" $filePath = "$mountedPath\Windows\System32\winpeshl.exe" $WinREVersion = (Get-Item $filePath).VersionInfo.FileVersionRaw.Revision dism /Unmount-Image /MountDir:"$mountedPath" /Discard Remove-Item -Path $mountedPath -Force -Recurse return [int]$WinREVersion
} # Main Execution
$WinREPath = GetWinREPath
$WinREVersion = GetWinREVersion
Write-Host "WinRE Version: $WinREVersion" -ForegroundColor Cyan