Skip to content

winre_restore.ps1

Corey Watson edited this page Dec 1, 2025 · 1 revision

winre_restore.ps1

Restore Windows Recovery Environment from downloaded files.

Overview

Restores Windows Recovery Environment (WinRE) by downloading Winre.wim and ReAgent.xml files from a specified URL and placing them in the Recovery folder. Fixes systems where WinRE has been corrupted or deleted.

Purpose

Repairs Windows Recovery Environment on systems where WinRE has been damaged, deleted, or is non-functional.

Prerequisites

  • Windows 10/11
  • Admin privileges required
  • Network connectivity to download URLs
  • Valid WinRE files hosted at specified URLs

Configuration

Required Inputs

  • WinreWimUrl: URL to download Winre.wim file
  • ReAgentXmlUrl: URL to download ReAgent.xml file
  • RecoveryPath: Path to Windows Recovery folder

Settings

  • Downloads files to TEMP then moves to Recovery folder
  • Disables WinRE before restore, re-enables after
  • Uses curl with retry and timeout

Behavior

  1. Disables WinRE (reagentc /disable)
  2. Downloads Winre.wim from specified URL
  3. Downloads ReAgent.xml from specified URL
  4. Moves files to C:\Windows\System32\Recovery
  5. Re-enables WinRE (reagentc /enable)

Security Notes

  • No secrets in logs
  • Downloads from specified URLs - ensure URLs are trusted
  • Modifies system recovery configuration

Exit Codes

  • 0: Success
  • 1: Failure

Example Output

[ INPUT VALIDATION ]
--------------------------------------------------------------
WinRE WIM URL   : https://your-server.com/Winre.wim
ReAgent XML URL : https://your-server.com/ReAgent.xml
Recovery Path   : C:\Windows\System32\Recovery

[ OPERATION ]
--------------------------------------------------------------
Disabling WinRE...
Downloading Winre.wim...
Downloading ReAgent.xml...
Moving files to Recovery folder...
Enabling WinRE...

[ RESULT ]
--------------------------------------------------------------
Status : Success

[ SCRIPT COMPLETED ]
--------------------------------------------------------------

Version History

  • v1.0.0 (2025-11-29): Initial Style A implementation

Links

Clone this wiki locally