{"id":75380,"date":"2024-06-03T17:31:02","date_gmt":"2024-06-03T12:01:02","guid":{"rendered":"http:\/\/198.58.113.91\/blog\/?p=75380"},"modified":"2024-06-03T18:03:33","modified_gmt":"2024-06-03T12:33:33","slug":"extend-windows-re-partition-powershell","status":"publish","type":"post","link":"https:\/\/www.winhelponline.com\/blog\/extend-windows-re-partition-powershell\/","title":{"rendered":"How to Extend the Windows RE Partition Using PowerShell"},"content":{"rendered":"<p>KB5034441 is a WinRE security update that patches the Winre.wim image. The Recovery partition needs 250 MB of free space for the KB5034441 update to install correctly.<\/p>\n<p>Almost every Windows 10 user has been affected by the <a href=\"https:\/\/www.winhelponline.com\/blog\/kb5034441-error-0x80070643\/\">KB5034441 error 0x80070643<\/a>. You can extend the Recovery partition using the <code>diskpart<\/code> command-line. However, end-users might find that command-line procedure complicated.<\/p>\n<p>So, here&#8217;s a PowerShell script from Microsoft that automatically extends the Recovery partition by 250 MB.<!--more--><\/p>\n<p><em>(Script source: <a href=\"https:\/\/learn.microsoft.com\/en-us\/windows-hardware\/manufacture\/desktop\/add-update-to-winre?view=windows-11#extend-the-windows-re-partition\" target=\"_blank\" rel=\"noopener\">Microsoft Learn<\/a>)<\/em><\/p>\n<div class=\"qt\"><em><strong>Editor&#8217;s note:<\/strong> Before proceeding, please <a href=\"https:\/\/www.winhelponline.com\/blog\/backup-winre-wim-image\/\">backup your Winre.wim image<\/a>. Also, as a <strong>general precaution<\/strong>, backup important files to an external drive before modifying the disk partitions, even though Microsoft&#8217;s PowerShell script (.PS1) makes appropriate validations before resizing the Recovery partition.<\/em><\/div>\n<h2>Extend Windows RE Partition Using PowerShell<\/h2>\n<ol>\n<li>First, restart Windows before you run the script. This is critical as there may be pending partition operations staged on your machine that must be finalized before the script can safely increase the WinRE partition size.<\/li>\n<li>Then, open an <strong>admin<\/strong> PowerShell and run:\n<pre class=\"powershell\">md C:\\Winrefix\\backup<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-75389\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/ps-create-folder.png\" alt=\"create folder - powershell\" width=\"752\" height=\"288\" \/><\/li>\n<li>Download <a href=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre.zip\"><strong>winre.ps1<\/strong><\/a> (zipped), unzip and extract the script file to the <strong>C:\\winrefix<\/strong> folder.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-75382 alignnone\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre_script_folder.png\" alt=\"winre resize script\" width=\"641\" height=\"126\" \/><\/li>\n<li>In the admin PowerShell window, type:\n<pre class=\"powershell\">Set-ExecutionPolicy -ExecutionPolicy Unrestricted<\/pre>\n<\/li>\n<li>Press <strong>Y<\/strong> when asked for confirmation.<\/li>\n<li>Next, type the following commands:\n<pre class=\"powershell\">cd\\\n\ncd winrefix\n\n.\\winre.ps1<\/pre>\n<p>The above executes the winre.ps1 script.<\/p>\n<h4>Sample output<\/h4>\n<pre>cmdlet winre.ps1 at command pipeline position 1\nSupply values for the following parameters:\n(Type !? for Help.)\n<strong>BackupFolder:<\/strong>\n<\/pre>\n<\/li>\n<li>When prompted, type the backup folder path as follows, and press Enter:\n<pre class=\"powershell\">c:\\winrefix\\backup<\/pre>\n<p>You&#8217;ll see an output similar to the following:<\/p>\n<h4>Sample output<\/h4>\n<pre>cmdlet winre.ps1 at command pipeline position 1\nSupply values for the following parameters:\n(Type !? for Help.)\nBackupFolder: c:\\winrefix\\backup\nStart time: 06\/03\/2024 14:47:32\nExamining the system...\nWindows RE status:         Enabled\nWindows RE location:       \\\\?\\GLOBALROOT\\device\\harddisk0\\partition3\\Recovery\\WindowsRE\nSystem directory: C:\\WINDOWS\\system32\nReAgent xml: C:\\WINDOWS\\system32\\Recovery\\ReAgent.xml\n\nCollecting OS and WinRE partition info...\nOS Disk: 0\nOS Partition: 2\nWinRE Partition: 3\nDisk PartitionStyle: MBR\nWinRE partition size info\n  Partition capacity: 650113024\n  Partition free space: 130801664\nWinRE Partition Offset: 209066131456\nWinRE Partition Type: Unknown\nOS partition size: 208960225280\nOS partition Offset: 105906176\nOS partition ends at: 209066131456\nWinRE partition starts at: 209066131456\n\nBackup Directory: [c:\\winrefix\\backup]\n\nVerifying if the WinRE partition needs to be extended or not...\n\nSummary of proposed changes\nWill shrink OS partition by 262144000\n  Current OS partition size: 208960225280\n  Target OS partition size after shrinking: 208698081280\nUnallocated space between OS and WinRE partition that will be used towards the new WinRE partition: 0\nWill extend WinRE partition size by 250MB\n  WinRE partition: Disk [0] Partition [3]\n  Current WinRE partition size: 650113024\n  New WinRE partition size:     912257024\nWinRE will be temporarily disabled before extending the WinRE partition and enabled automatically in the end\n\nThe contents of the old WinRE partition will be backed up to [c:\\winrefix\\backup]\n\nPlease reboot the device before running this script to ensure any pending partition actions are finalized\n\n<strong>Would you like to proceed? Y for Yes and N for No: Y<\/strong>\n<\/pre>\n<li>Press <strong>Y<\/strong>\n<div class=\"newline\">You&#8217;ll see the output similar to the following:<\/div>\n<h4>Sample output<\/h4>\n<pre>Proceeding with changes...\n\nNote: To prevent unexpected results, please do not interrupt the execution or restart your system\n\nLoading [C:\\WINDOWS\\system32\\Recovery\\ReAgent.xml] ...\nClearing stage location info...\nSaving changes to [C:\\WINDOWS\\system32\\Recovery\\ReAgent.xml]...\nDisabling WinRE...\nREAGENTC.EXE: Operation Successful.\n\nVerifying that WinRE wim exists in downlevel at default location\nPerforming repartition to extend the WinRE partition ...\nShrinking the OS partition to create a larger WinRE partition\nResizing the OS partition to: [208698081280]...\nTarget partition size: 208698081280\nSize of OS partition after shrinking: 208698081280\n\nCopying content on WinRE partition from [\\\\?\\Volume{098cc206-0000-0000-0000-50ad30000000}\\] to [c:\\winrefix\\backup]...\nCopying [\\\\?\\Volume{098cc206-0000-0000-0000-50ad30000000}\\recovery] to [c:\\winrefix\\backup\\recovery]...\nBackup completed\n\nDeleting WinRE partition: Disk [0] Partition [3]...\n\nCreating new WinRE partition...\nTarget size: 912257024\nCreating temporary diskpart script to create Recovery partition on MBR disk...\nTemporary diskpart script file: C:\\Users\\Ramesh\\AppData\\Local\\Temp\\ExtendWinRE_MBR_PowershellScript.txt\nExecuting diskpart script...\nDiskpart script executed successfully\nDeleting temporary diskpart script file...\nNew Partition index: 3\nRe-enabling WinRE...\nREAGENTC.EXE: Operation Successful.\n\n\nWinRE Information:\nWindows RE status:         Enabled\nWindows RE location:       \\\\?\\GLOBALROOT\\device\\harddisk0\\partition3\\Recovery\\WindowsRE\nWinRE Partition Index: 3\n  Partition capacity: 912257024\n  Partition free space: 392609792\n\nOS Information:\nOS partition size: 208698081280\nOS partition Offset: 105906176\nEnd time: 06\/03\/2024 14:48:56\n\nThe contents of the old WinRE partition has been backed up to [c:\\winrefix\\backup]\n\n<strong>Successfully completed the operation<\/strong>\n<\/pre>\n<\/li>\n<li>To revert the script execution policy to default, type the following command in PowerShell:\n<pre class=\"powershell\">Set-ExecutionPolicy -ExecutionPolicy Restricted<\/pre>\n<\/li>\n<li>Press <strong>Y<\/strong> when asked for confirmation.<\/li>\n<\/ol>\n<p>That&#8217;s it. The PowerShell script has successfully resized the Recovery partition by shrinking the OS partition. The Recovery partition should now be 250 MB larger than it was before.<\/p>\n<hr \/>\n<h3>Screenshots<\/h3>\n<p><strong>Disk Management<\/strong><\/p>\n<p>Before resizing the Recovery partition:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-75388\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre_size_before.png\" alt=\"recovery partition size - disk management\" width=\"752\" height=\"103\" \/><\/p>\n<p>After extending the partition by 250 MB:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-75383\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre_size_after.png\" alt=\"recovery partition size - disk management\" width=\"749\" height=\"107\" \/><\/p>\n<p><strong>PowerShell window<\/strong><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-75385\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre_resize_ps_output_ss_1.png\" alt=\"recovery partition extend - powershell output\" width=\"1238\" height=\"1010\" srcset=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre_resize_ps_output_ss_1.png 1238w, https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre_resize_ps_output_ss_1-768x627.png 768w\" sizes=\"auto, (max-width: 1238px) 100vw, 1238px\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-75386\" src=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre_resize_ps_output_ss_2.png\" alt=\"recovery partition extend - powershell output\" width=\"1238\" height=\"880\" srcset=\"https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre_resize_ps_output_ss_2.png 1238w, https:\/\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre_resize_ps_output_ss_2-768x546.png 768w\" sizes=\"auto, (max-width: 1238px) 100vw, 1238px\" \/><\/p>\n<p>(Right-click on each image and click &#8220;Open in a new tab&#8221; to read the output in those screenshots.)<\/p>\n<hr \/>\n<h3>More information<\/h3>\n<ul>\n<li>The PowerShell script mentioned in this article works on both <a href=\"https:\/\/www.winhelponline.com\/blog\/find-if-disk-is-mbr-or-gpt\/\">MBR and GPT-based disks<\/a>.<\/li>\n<li>If WinRE is disabled on the computer, the script doesn&#8217;t do anything.<\/li>\n<li>If WinRE is located in the OS partition, the script does nothing, as no resizing is required.<\/li>\n<li>The script backs up the old WinRE partition content to the specified backup folder. It uses the backup in case of failure to restore the original partition.<\/li>\n<li>If the script detects more than 250 MB of free space in the WinRE partition, it doesn&#8217;t resize it.<\/li>\n<li>If the WinRE partition is not after OS partition, it can&#8217;t extend the WinRE partition. Instead, it creates a new WinRE partition after the OS partition.<\/li>\n<li>The script doesn&#8217;t proceed further if WinRE is located on the System partition.<\/li>\n<\/ul>\n<p>I hope that this information helps.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>KB5034441 is a WinRE security update that patches the Winre.wim image. The Recovery partition needs 250 MB of free space for the KB5034441 update to install correctly. Almost every Windows 10 user has been affected by the KB5034441 error 0x80070643. You can extend the Recovery partition using the diskpart command-line. However, end-users might find that &#8230; <a title=\"How to Extend the Windows RE Partition Using PowerShell\" class=\"read-more\" href=\"https:\/\/www.winhelponline.com\/blog\/extend-windows-re-partition-powershell\/\" aria-label=\"Read more about How to Extend the Windows RE Partition Using PowerShell\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_post_was_ever_published":false},"categories":[8],"tags":[396,680],"class_list":["post-75380","post","type-post","status-publish","format-standard","hentry","category-windows-10","tag-powershell","tag-windows-recovery-environment"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":69710,"url":"https:\/\/www.winhelponline.com\/blog\/kb5034441-error-0x80070643\/","url_meta":{"origin":75380,"position":0},"title":"KB5034441 Update error 0x80070643","author":"Ramesh","date":"January 10, 2024","format":false,"excerpt":"On many Windows 10 systems, the update KB5034441 (Windows Recovery Environment update for Windows 10 21H2 and 22H2) failed with the error code 0x80070643. 0x80070643 (\"ERROR_INSTALL_FAILURE\") is a generic error code which means \"Fatal error during installation.\" The DISM log may show the following entries: [16088] ImageUnmarshallHandle: Reconstituting wim at\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"KB5034441 wushowhide.diagcab","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/01\/wushowhide-winre-update.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/01\/wushowhide-winre-update.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/01\/wushowhide-winre-update.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":78048,"url":"https:\/\/www.winhelponline.com\/blog\/resize-winre-recovery-partition\/","url_meta":{"origin":75380,"position":1},"title":"How to Resize the Recovery Partition in Windows","author":"Ramesh","date":"March 6, 2025","format":false,"excerpt":"The Recovery partition stores Winre.wim, an image needed to boot into the Windows Recovery Environment (WinRE). If the recovery partition is small, the system might fail when servicing the Winre.wim image. For instance, you may encounter error 0x80070643 when installing WinRE security updates if the recovery partition is not big\u2026","rel":"","context":"In &quot;Utilities&quot;","block_context":{"text":"Utilities","link":"https:\/\/www.winhelponline.com\/blog\/category\/utilities\/"},"img":{"alt_text":"resize recovery partition using aomei","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2025\/03\/resize_winre_6-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2025\/03\/resize_winre_6-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2025\/03\/resize_winre_6-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2025\/03\/resize_winre_6-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":75767,"url":"https:\/\/www.winhelponline.com\/blog\/winre-partition-size-and-free-space\/","url_meta":{"origin":75380,"position":2},"title":"How to Determine WinRE Partition&#8217;s Capacity and Free Disk Space","author":"Ramesh","date":"July 1, 2024","format":false,"excerpt":"Disk Management always tells you that the EFI and Recovery partitions have 100% free space, which is incorrect. Disk Management cannot enumerate those two partitions because of the TypeID and attributes used for the EFI and Recovery partitions. RELATED: How to Extend the Windows RE Partition Using PowerShell Find WinRE\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"find recovery partition size and free disk space","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/07\/recovery-partition-free-space-1.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/07\/recovery-partition-free-space-1.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/07\/recovery-partition-free-space-1.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/07\/recovery-partition-free-space-1.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":76193,"url":"https:\/\/www.winhelponline.com\/blog\/find-kb5034441-is-installed\/","url_meta":{"origin":75380,"position":3},"title":"How to Find if KB5034441 has been installed on your PC","author":"Ramesh","date":"July 31, 2024","format":false,"excerpt":"The WinRE security update KB5034441 fixes a BitLocker vulnerability in WinRE. After resizing the recovery partition, the KB5034441 update installs quickly. You wonder if the KB5034441 update has been installed or not. It may not appear in the Windows Update history on some systems, or the old entries may have\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"find if kb5034441 installed","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/07\/winreversion_dism.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/07\/winreversion_dism.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/07\/winreversion_dism.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/07\/winreversion_dism.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":75373,"url":"https:\/\/www.winhelponline.com\/blog\/backup-winre-wim-image\/","url_meta":{"origin":75380,"position":4},"title":"How to Backup your WinRE Image (Winre.wim)","author":"Ramesh","date":"June 3, 2024","format":false,"excerpt":"The Windows Recovery Environment is powered by the Winre.wim image, usually located in the Recovery partition or, in some cases, in the OS partition itself. You may have to back up your Winre.wim image in some situations, e.g., before or after servicing Winre.wim, or when you want to resize the\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"enable winre using reagentc and get confirmation","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre-enable-reagentc.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre-enable-reagentc.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre-enable-reagentc.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2024\/06\/winre-enable-reagentc.png?resize=700%2C400&ssl=1 2x"},"classes":[]},{"id":57641,"url":"https:\/\/www.winhelponline.com\/blog\/mystery-drive-appears-system-properties\/","url_meta":{"origin":75380,"position":5},"title":"Mystery Drive appears in System Properties Protection tab","author":"Ramesh","date":"July 2, 2023","format":false,"excerpt":"When you open System Properties and click the System Protection tab to create a restore point, you may notice a mystery drive appearing with the volume GUID string (e.g., \\\\?\\Volume{a6810e9c-8234-4cd1...) instead of a drive letter. The drive may not appear in File Explorer. Cause The mystery drive that appears in\u2026","rel":"","context":"In &quot;Windows 10&quot;","block_context":{"text":"Windows 10","link":"https:\/\/www.winhelponline.com\/blog\/category\/microsoft\/windows\/windows-10\/"},"img":{"alt_text":"unknown volume mystery drive in system restore tab","src":"https:\/\/i0.wp.com\/www.winhelponline.com\/blog\/wp-content\/uploads\/2023\/07\/system-protection-mystery-drive-1.png?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/75380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/comments?post=75380"}],"version-history":[{"count":0,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/posts\/75380\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/media?parent=75380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/categories?post=75380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.winhelponline.com\/blog\/wp-json\/wp\/v2\/tags?post=75380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}