Skip to content

Instantly share code, notes, and snippets.

@p0w3rsh3ll
Last active April 2, 2023 09:54
Show Gist options
  • Save p0w3rsh3ll/4ba19e27326db83474d01fe6d73d78dc to your computer and use it in GitHub Desktop.
Save p0w3rsh3ll/4ba19e27326db83474d01fe6d73d78dc to your computer and use it in GitHub Desktop.
$null,$RELoc = ((& (Get-Command "$($env:systemroot)\system32\ReAgentC.exe") @('/info')) | Where-Object { $_ -match 'Windows\sRE\slocation:' } ) -split ':'
$RELoc = $RELoc.Trim()
Get-WindowsImageContent -ImagePath "$($RELoc)\winre.wim" -Index 1 |
Where-Object { $_ -match 'Windows\\WinSxS\\amd64_microsoft-windows-bootmenuux_.+_(?<Version>(\d{1,5}\.)+\d{1,5})_.+\\BootMenuUX\.dll'} |
ForEach-Object { ([regex]'Windows\\WinSxS\\amd64_microsoft-windows-bootmenuux_.+_(?<Version>(\d{1,5}\.)+\d{1,5})_.+\\BootMenuUX\.dll').Matches($_) |
Select-Object -Expand Groups | Where-Object Name -eq 'Version' | Select-Object -ExpandProperty Value}| ForEach-Object { try {[version]$_}catch{ 'Failed'}} |
Sort-Object -Descending | Select-Object -First 1 | ForEach-Object ToString
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment