$winrepath = & cmd /c "chcp 437 > null && reagentc /info" | Select-String "Windows RE location" $winrepath = ($winrepath | Select-String "Windows RE location").ToString() -replace ".*Windows RE location:\s*","" if ($winrepath -eq "") { Write-Host "WinRE: Disabled" } else { $winrepath = $winrepath + "\winre.wim" $imageinfo = & cmd /c "chcp 437 > null && DISM /Get-ImageInfo /ImageFile:$winrepath /index:1" $ver = ($imageinfo | Select-String "Version \s*:").ToString() -replace ".*Version \s*:\s*","" $rev = ($imageinfo | Select-String "ServicePack Build \s*:").ToString() -replace ".*ServicePack Build \s*:\s*","" Write-Host "WinRE version: $ver.$rev" }