Public/OS/Get-WinRE.ps1
<#
Copyright © 2024 Integris. For internal company use only. All rights reserved. #> FUNCTION Get-WinRE { <# .SYNOPSIS Retrieves information about the Windows Recovery Environment (WinRE). .DESCRIPTION This function collects and returns details about the Windows Recovery Environment, including its status, location, and associated recovery images. .PARAMETER None This function does not take any parameters. .EXAMPLE Get-WinRE Retrieves and displays information about the Windows Recovery Environment. .NOTES The function uses REAGENTC to query the WinRE configuration. #> [CmdletBinding()] param( [string[]]$LogonType = @("Logon","Logoff") ) IF (!(Test-AdministratorElevation)) { RETURN } $Results = @() TRY { $REAGENTC = REAGENTC /Info } CATCH {} $Results += New-Object PSObject -WarningAction SilentlyContinue -Property @{ WinREStatus = ($REAGENTC | Select-String -Pattern "Windows RE status:").ToString().Replace("Windows RE status:","").Replace(" ","") WinRELocation = ($REAGENTC | Select-String -Pattern "Windows RE location:").ToString().Replace("Windows RE location:","").Replace(" ","") BCDIdentifier = ($REAGENTC | Select-String -Pattern "Boot Configuration Data").ToString().Replace("Boot Configuration Data (BCD) identifier:","").Replace(" ","") RecoveryImageLocation = ($REAGENTC | Select-String -Pattern "Recovery image location:").ToString().Replace("Recovery image location:","").Replace(" ","") RecoveryImageIndex = ($REAGENTC | Select-String -Pattern "Recovery image index:").ToString().Replace("Recovery image index:","").Replace(" ","") CustomImageLocation = ($REAGENTC | Select-String -Pattern "Custom image location:").ToString().Replace("Custom image location:","").Replace(" ","") CustomImageIndex = ($REAGENTC | Select-String -Pattern "Custom image index:").ToString().Replace("Custom image index:","").Replace(" ","") } RETURN $Results | Select-Object WinREStatus, WinRELocation, BCDIdentifier, RecoveryImageLocation, RecoveryImageIndex, CustomImageLocation, CustomImageIndex } |