Skip to content

winreagent_cleanup.ps1

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

winreagent_cleanup.ps1

Clean up WinRE agent temporary files.

Overview

Deletes the C:$WinREAgent folder which contains temporary Windows Recovery Environment update files. This folder can consume significant disk space and is safe to delete after WinRE updates are complete.

Purpose

Reclaims disk space consumed by temporary WinRE update files on managed Windows endpoints.

Prerequisites

  • Windows 10/11
  • Admin privileges recommended

Configuration

Required Inputs

  • FolderPath: Path to WinREAgent folder (default: C:$WinREAgent)

Settings

  • Deletes folder recursively if it exists
  • Hidden/system folder deletion handled

Behavior

  1. Checks if C:$WinREAgent folder exists
  2. If exists, deletes folder and all contents
  3. Reports result

Security Notes

  • No secrets in logs
  • Only deletes specified system folder

Exit Codes

  • 0: Success (folder deleted or not found)
  • 1: Failure

Example Output

[ INPUT VALIDATION ]
--------------------------------------------------------------
Folder Path : C:\$WinREAgent

[ OPERATION ]
--------------------------------------------------------------
Checking for WinREAgent folder...
Folder found, deleting...

[ RESULT ]
--------------------------------------------------------------
Status : Success
Action : Folder deleted

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

Version History

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

Links

Clone this wiki locally