PowerShell script to safely move/recreate Windows Recovery Environment (WinRE) to a new Recovery partition.
Keywords: WinRE Windows Recovery Recovery Partition reagentc KB5034441 KB5028997 CVE-2024-20666 BitLocker Windows Update Fix Partition Resize GPT UEFI
This script helps fix common Windows Update errors related to WinRE partition:
- KB5034441 / KB5028997 installation failures
- "Windows Recovery Environment servicing failed" errors
- Recovery partition too small for security updates
- CVE-2024-20666 BitLocker security update issues
| 🇹🇷 Türkçe | 🇬🇧 English |
|---|---|
| Bu script'i çalıştırmadan önce mutlaka tam sistem yedeği alın! Disk/partition işlemleri geri dönüşü olmayan veri kaybına yol açabilir. | Take a full system backup before running this script! Disk/partition operations can cause irreversible data loss. |
Winre-Fix.ps1 Windows Recovery Environment (WinRE) bileşenini güvenli bir şekilde yeni bir Recovery partition'a taşıyan/yeniden oluşturan bir PowerShell betiğidir.
- Desteklenen İşletim Sistemleri:
- Windows 10 (1903+)
- Windows 11 (tĂĽm sĂĽrĂĽmler)
- Windows Server 2016 / 2019 / 2022 / 2025
- Yönetici (Administrator) hakları ile çalıştırma zorunludur
- PowerShell 5.1 veya PowerShell 7+
- GPT disk (MBR deÄźil) + UEFI boot modu
- Yedek alın! Partition ve disk işlemleri veri kaybına yol açabilir.
- Ă–nce
-WhatIfile simülasyon çalıştırın. - Script sadece Disk 0 üzerinde çalışır.
| Parametre | Açıklama |
|---|---|
-WhatIf |
Gerçek değişiklik yapmadan adımları simüle eder (güvenli test modu) |
-Force |
Onay istemeden tüm adımları uygular + minimum alan uyarılarını geçer |
-Verbose |
Ayrıntılı çıktı/log için verbose modu |
1. PRE-CHECK: Disk 0'da "Unallocated" (boş) alan var mı?
├─ Yok → HATA: "No unallocated space found" → Çıkış
├─ < 1.2 GB → Uyarı, -Force gerekli
└─ >= 1.2 GB → OK, devam
↓
2. Yedek onayı iste (YES yazılmalı, -Force/-WhatIf ile atlanır)
↓
3. Recovery partition'ı bul (GPT Type ile tüm partition'ları tarar)
├─ Bulunamadı → HATA → Çıkış
└─ Bulundu → OK, devam
↓
4. Partition doğrulama (boyut < 10 GB olmalı)
├─ Çok büyük → HATA: "Too large, might be Windows!" → Çıkış
└─ OK → devam
↓
5. WinRE disable et (reagentc /disable)
↓
6. Eski Recovery partition'ı sil
↓
7. C: sürücüsünü genişlet (1 GB rezerv bırakır)
↓
8. Yeni Recovery partition oluĹźtur + NTFS formatla
↓
9. GPT Type + Hidden attribute ayarla (diskpart)
↓
10. WinRE enable et (reagentc /enable)
↓
TAMAMLANDI!
# 1. SimĂĽlasyon (gĂĽvenli test)
.\Winre-Fix.ps1 -WhatIf -Verbose
# 2. Normal çalıştırma (onay sorar)
.\Winre-Fix.ps1
# 3. Otomatik çalıştırma (onay sormaz)
.\Winre-Fix.ps1 -Force- Konum:
C:\temp\WinRE-Fix-Log.txt
Winre-Fix.ps1 is a PowerShell script that safely moves/recreates the Windows Recovery Environment (WinRE) to a new Recovery partition.
- Supported Operating Systems:
- Windows 10 (1903+)
- Windows 11 (all versions)
- Windows Server 2016 / 2019 / 2022 / 2025
- Run as Administrator (required)
- PowerShell 5.1 or PowerShell 7+
- GPT disk (not MBR) + UEFI boot mode
- Back up your data! Disk/partition operations can cause data loss.
- Run with
-WhatIffirst to simulate. - Script only works on Disk 0.
| Parameter | Description |
|---|---|
-WhatIf |
Simulate steps without making changes (safe test mode) |
-Force |
Skip confirmation prompts + override minimum space warnings |
-Verbose |
Enable detailed output/logging |
1. PRE-CHECK: Is there "Unallocated" space on Disk 0?
├─ None → ERROR: "No unallocated space found" → Exit
├─ < 1.2 GB → Warning, requires -Force
└─ >= 1.2 GB → OK, proceed
↓
2. Backup confirmation (must type YES, skipped with -Force/-WhatIf)
↓
3. Find Recovery partition (scans all partitions by GPT Type)
├─ Not found → ERROR → Exit
└─ Found → OK, proceed
↓
4. Partition validation (size must be < 10 GB)
├─ Too large → ERROR: "Might be Windows drive!" → Exit
└─ OK → proceed
↓
5. Disable WinRE (reagentc /disable)
↓
6. Delete old Recovery partition
↓
7. Extend C: drive (reserves 1 GB)
↓
8. Create new Recovery partition + format NTFS
↓
9. Set GPT Type + Hidden attribute (diskpart)
↓
10. Enable WinRE (reagentc /enable)
↓
COMPLETE!
# 1. Simulation (safe test)
.\Winre-Fix.ps1 -WhatIf -Verbose
# 2. Normal run (asks for confirmation)
.\Winre-Fix.ps1
# 3. Automatic run (no confirmation)
.\Winre-Fix.ps1 -Force- Location:
C:\temp\WinRE-Fix-Log.txt
| Check | Description |
|---|---|
| đź”’ Administrator | Script exits if not run as Administrator |
| đź’ľ Unallocated Space | Checks for free disk space before any changes |
| âś… Backup Confirmation | Requires typing "YES" before proceeding (skipped with -Force) |
| 🔍 GPT Type Scan | Finds Recovery partition by scanning all partitions for correct GPT type |
| 📏 Size Sanity Check | Recovery partition must be < 10 GB (prevents deleting Windows!) |
| 📝 Full Logging | All operations logged to C:\temp\WinRE-Fix-Log.txt |
| 🛡️ Winre.wim Check | Verifies recovery image exists before enabling WinRE |
MIT License - Use at your own risk.
Created for safe WinRE partition management on Windows systems.