• PowerShell script to test partition sizes

    Home » Forums » Admin IT Lounge » Managing updates in organizations » PowerShell script to test partition sizes

    Author
    Topic
    #2628791
    Script courtesy of Shawn Hall

     

    $winreloc  = (reagentc /info | select-string "Windows RE location:\s+(([^\r\n]+)disk(\d+)\\partition(\d+)\\([^\r\n]+))");$winrepath = $winreloc.Matches.groups[1].value.trim()$winredisk = $winreloc.Matches.groups[3].value$winrepart = $winreloc.Matches.groups[4].valueWrite-Host "WinRE is at disk $winredisk partition $winrepart"$winresize = (Get-Volume -FilePath $winrepath | select SizeRemaining,Size )$winrefree = [math]::Round($winresize.SizeRemaining/1MB)Write-Host WinRE has $winrefree MB free space.if ($winresize.Size -lt 1GB) {        Write-Host WinRE needs to be larger.} elseif ($winresize.SizeRemaining -lt 250MB) {        Write-Host WinRE needs more free space.} else {        Write-Host WinRE is large enough.}
    
    
    

    Susan Bradley Patch Lady/Prudent patcher

    • This topic was modified 1 year, 3 months ago by Susan Bradley.
    • This topic was modified 1 year, 3 months ago by Will Fastie.
    7 users thanked author for this post.
    Viewing 57 reply threads
    Author
    Replies
    • #2628809

      Nice script!

      You can add Clear-Host as the first line to cleanup the output.

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      1 user thanked author for this post.
    • #2628825

      This script will need to be run with admin privileges. And you need to set the PowerShell environment to allow script execution.

      cheers, Paul

      1 user thanked author for this post.
    • #2628842

      You can run free portable MiniTool partition wizard.

    • #2628937

      That script is set such that, if WinRE is less than 1 GB, it’ll indicate it needs to be larger which isn’t true.

      From what I’ve found checking multiple different Windows 10 PC’s I support, the actual size of the existing WinRE can vary quite a bit, everything from less than 500 MB (smallest was 442 MB)  to more than 1 GB (largest was 1.13 GB).

      To properly indicate whether the WinRE Security Update will fail or not on a particular PC, the script should only check whether an existing WinRE (regardless of how large it is) has at least 250 MB of free space (see my Recovery partition free space needed to install the WinRE security update topic for details.)

      3 users thanked author for this post.
      • #2628969

        n0ads,

        Here’s a modified script to incorporate your comments.

        Clear-Host
        $winreloc = (reagentc /info | 
           select-string “Windows RE location:\s+(([^\r\n]+)disk(\d+)\\partition(\d+)\\([^\r\n]+))”);
        
        $winrepath = $winreloc.Matches.groups[1].value.trim()
        $winredisk = $winreloc.Matches.groups[3].value
        $winrepart = $winreloc.Matches.groups[4].value
        
        Write-Host “WinRE is at disk $winredisk partition $winrepart”
        
        $winresize = (Get-Volume -FilePath $winrepath | select SizeRemaining,Size )
        $winrefree = [math]::Round($winresize.SizeRemaining/1MB)
        Write-Host "`nWinRE has $winrefree MB free space."
        
        if ($winresize.SizeRemaining -lt 250MB) {
          Write-Host $("nWinRE needs more free space.n" +
                       "t250Mb free is required for update!n")
        } 
        else {
              Write-Host "WinRE is large enough."
             }
        

        Sample Output:

        WinRE is at disk 0 partition 4
        
        WinRE has 85 MB free space.
        
        WinRE needs more free space.
        	250Mb free is required for update!
        PS> 
        

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

        5 users thanked author for this post.
        • #2629398

          Sample Output:

          WinRE is at disk 0 partition 4

          WinRE has 85 MB free space.

          WinRE needs more free space.
          250Mb free is required for update!
          PS>

          My output has some a strange ‘n’ or three and a ‘t’.
          free-space-Retired-Geek

          • #2629400

            WCHS,

            They are the new line (‘n) and tab (‘t) characters and should be interpreted as such.
            Note: I had to use the apostrophe in place of the back tick as WordPress renders them.

            What version of PowerShell are you running?
            Are you running if from the Windows Terminal?

            May the Forces of good computing be with you!

            RG

            PowerShell & VBA Rule!
            Computer Specs

            • #2629474

              Retired Geek,

              It looks like the backtick was omitted in front of those 3 instances of ‘n’ and the 1 instance of ‘t’ in the posted BBcode. But, there is a backtick in front of the ‘n’ in the line of posted BBcode that writes the message “WinRE has 52 MB free space.” And, in that case, there was no ‘n’ in the new line in the output message, as you can see in the screenshot.

              The posted BBcode is at #2628969. I just copied it from the posted BBcode and pasted it at the PS prompt that I get at right-click on Start Menu > Windows PowerShell (Admin).

            • #2629597

              the posted BBcode {everywhere}

              Post-script: It’s too late to edit this — I should have said ‘BBcoded post’, not ‘posted BBcode’.

              This refers to the PowerShell script in the post, displayed by using BBcode to get the grey background and, if the script line is too long, the scrollbar at the bottom.

            • #2629602

              WCHS,

              Right you are! This is why I like to post my PS Scripts to my OneDrive shared folder.
              Then I know it will be right when someone downloads it.

              Don’t know why when I use the {pre} {/pre} tags it doesn’t stop all changes by Word Press. Please note substitute <> for {} above!

              May the Forces of good computing be with you!

              RG

              PowerShell & VBA Rule!
              Computer Specs

    • #2628970

      Based on my personal experience a minimum total disk space of 1 GB and minimum free disk space of 250 MB for the Win RE partition is not an absolute requirement that determines if the KB5034441 Windows Recovery Environment (WinRE) update will install successfully.

      Prior to installing the Jan 2024 Patch Tuesday updates on my Win 10 machine (BitLocker turned OFF) I ran reagentc /info and fsutil volume diskfree commands in an elevated command prompt that showed that my WinRE partition (harddisk0/partition4) only had 990 MB of total disk space and 123.0 MB of free space, but the Win RE KB5034441 update was installed by Windows Update without any errors. See my 16-Jan-2024 post # 2628138 of Susan Bradley’s Ready for the new patching year? for further details.

      WinRE-Partition-Location-and-Free-Disk-Space-BEFORE-KB5034441-Installed-15-Jan-2024-1

      WIn-10-Pro-v22H2-WIndows-Update-History-KB6034441-Successful-16-Jan-2024

      After installing KB5034441 my fsutil volume diskfree command showed the free disk space for my WinRE partition had decreased to 96.7 MB, which is identical to what Shawn’s PowerShell script now reports.

      Win-10-Pro-v22H2-Command-Prompt-WinRE-Partition-Location-and-Free-Disk-Space-After-KB5034441-16-Jan-2024-1

      Win-10-Pro-v22H2-PowerShell-Command-for-WinRE-Partition-Free-Disk-Space-19-Jan-2024
      ————-
      Dell Inspiron 5584 * 64-bit Win 10 Pro v22H2 build 19045.3930 * Firefox v121.0.1 * Microsoft Defender v4.18.23110.3-1.1.23110.2 * Malwarebytes Premium v4.6.8.311-1.0.2242 * Macrium Reflect Free v8.0.7783

      2 users thanked author for this post.
    • #2629078

      I’m seeing IT folks recommend that going forward the recovery partition is 1 gig to ‘future proof’ patching this going forward.

      Susan Bradley Patch Lady/Prudent patcher

      1 user thanked author for this post.
      • #2629097

        I’m seeing IT folks recommend that going forward the recovery partition is 1 gig to ‘future proof’ patching this going forward.

        Mine’s been 1GB since Windows 7.

        Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
        We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
        We were all once "Average Users".

        • #2629617

          Well you may have done it that way, but Microsoft didn’t.

          Susan Bradley Patch Lady/Prudent patcher

          • #2629626

            Well you may have done it that way, but Microsoft didn’t.

            There are lots of things about Windows that Microsoft didn’t/did do that I do/don’t do.  My WindowsRE is on a different SSD than Windows, as well.  Works great, doesn’t get munged by Microsoft, except once.

            One of the feature updates (22H2 or 23H1, I don’t really remember) created a WindowsRE behind the Windows partition by reducing the size of the Windows partition and creating a sizable WindowsRE partition.  I noticed the size difference for my Windows partition in File Explorer, and looked into it.

            I booted into my BootIt UEFI USB and deleted that WindowsRE, resized my Windows partition back to it’s original size, booted back into Windows, used DISKPART to assign a drive letter to my WindowsRE partition, used DISM to extract the Winre.wim from my Windows ISO, used xcopy to copy it into my WindowsRE partition (Microsoft, in their wisdom, had deleted it) then used Reagentc to enable it.

            Back into DISKPART to remove the drive letter, then Reagentc /info to make sure everything was in place and in working order, opened Image For Windows to add its functionality to the WindowsRE via the Utilities button, then Settings > Windows Update > Advanced options > Recovery > Advanced startup > Restart now and booted into WindowsRE.  Everything was as it was before Microsoft intervened.  Took thirty, maybe forty or so minutes start to finish after I had discovered the discrepancy in my Windows partition size.

            It’s covered in WindowsRE.  I started that in Windows 7, and I’ve since updated those web pages for Windows 10.  It works the same way in Windows 11.

            Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
            We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
            We were all once "Average Users".

            1 user thanked author for this post.
        • #2635206

          On my NUC-11, originally self-installed Win 10 Pro, upgraded to Win 11 Pro, the Recovery Partition was much smaller than 1 GB. I had to increase the size to get it that large. The same was true, though the original size was much larger than in the NUC, with my recently bought, originally Windows 11 Pro Powerspec B685 PC from my local Micro Center. (This is really similar to the ASUS Armoury Crate PC.) So no, Win 7 upward does not by default make the Recovery Partition as large as 1 GB. Far less.

          -- rc primak

    • #2629620

      Mine’s been 1GB since Windows 7

      From what I have seen default size after Windows clean install for recovery partition is ~500MB.

      1 user thanked author for this post.
      • #2629628

        From what I have seen default size after Windows clean install for recovery partition is ~500MB.

        I don’t do clean installs, and I rarely do default anything.  I have enough room in my 1GB partition for other tools that can run in that environment, such as Image For Windows.

        Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
        We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
        We were all once "Average Users".

        2 users thanked author for this post.
    • #2629638

      Utilities button, then Settings > Windows Update > Advanced options > Recovery > Advanced startup > Restart now and booted into WindowsRE.

      One tip to get there faster, hold the Shift Button while you restart. It comes right up to the light blue start-up screen.

      2 users thanked author for this post.
    • #2630896

      This script will need to be run with admin privileges

      That’s an important point. No matter how you run the script – PowerShell ISE, Visual Studio Code with the PS extension – the environment must be at an elevated level.

    • #2631948

      RetiredGeek and I have been working on an improved detection script to identify the active recovery partition and report its size and available free space. The revised script can be downloaded from our repository.

      The output from the script looks like this:

      Get Partition Info results

      There are three possibilities for the existence of the recovery partition – none, one, or more than one. For one or more, the script will return the correct information. But if there is no recovery partition, we think the script reports the bootable OS partition.

      Based on some testing that Susan and I have done, we think Microsoft’s guidance about there needing to be 250MB of free space in the recovery partition is not entirely accurate. In one case, the update was installed with much less than that and succeeded, resulting in less free space than was previously available. In another case, the update installed and more free space was available. As Susan has pointed out, Microsoft’s documentation about this is horrible.

      If you have any ideas about improving the script, let us know.

      6 users thanked author for this post.
      • #2631957

        f you have any ideas about improving the script, let us know.

        Hi Will Fastie / RetiredGeek:

        I know nothing about writing PowerShell scripts, but would it be possible to change your script so it detects the version and build of the winre.wim image in addition to the total / free size of the WinRE partition?

        I’m one of those people who successfully installed the WinRE KB5034441 update with Windows Update even though the free disk space for my WinRE partition was below 250 MB.  See the images in my 19-Jan-2024 post # 2628970 above.

        The reagentc /info command showed that my WinRE partiton was on harddisk0/partition4, and I also ran the command Dism /Get-ImageInfo /ImageFile:\\?\GLOBALROOT\device\harddisk0\partition4\Recovery\WindowsRE\winre.wim /index:1 in a elevated command prompt (see the MS Learn support article https://learn.microsoft.com/en-us/windows-hardware/manufacture/desktop/add-update-to-winre?view=windows-11#check-the-winre-image-version) before and after KB5034441 was installed.  This confirmed that the version number of my winre.wim image increased from Version 10.0.19041 / ServicePack Build 3562 (last modified 12-Oct-2023) to Version 10.0.19041 / ServicePack Build 3920 (last modified 16-Jan-2024) after KB5034441 was installed. Here’s the “before” …

        Win-10-Pro-v22H2-Command-Prompt-Dism-WinRE-Serivce-Pack-Build-3920-Before-KB5034441-15-Jan-2024

        … and “after” results.

        Win-10-Pro-v22H2-Command-Prompt-Dism-WinRE-Serivce-Pack-Build-3920-After-KB5034441-16-Jan-2024-1
        ————-
        Dell Inspiron 5584 * 64-bit Win 10 Pro v22H2 build 19045.3930 * Firefox v122.0.0 * Microsoft Defender v4.18.23110.3-1.1.23110.2 * Malwarebytes Premium v4.6.8.311-1.0.2249 * Macrium Reflect Free v8.0.7783

        3 users thanked author for this post.
    • #2631964

      … would it be possible to change your script so it detects the version and build of the winre.wim image

      Yes, but it’s beyond the scope of work I was willing to do. My purpose was to provide a means to determine the available free space in a recovery partition so folks could determine their situation if the WinRE update failed. It’s bad enough that I can’t definitively deal with the absence of a recovery partition. Until a solution is found for that, I don’t want to add more code that might present further complications.

      Besides, you’ve published a method of obtaining the WinRE image version that does not require a script.

      5 users thanked author for this post.
    • #2632340

      This is the Microsoft link explaining how to resize the WinRE partition:

      https://support.microsoft.com/en-us/topic/kb5028997-instructions-to-manually-resize-your-partition-to-install-the-winre-update-400faa27-9343-461c-ada9-24c8229763bf

      These instructions will recreate the WinRE partition to the right of the existing partitions, leaving an empty space where the WinRE partition initially was, not a neat solution.

      Personally, first I will shrink the windows partition using Disk Management tool, then I will backup all partitions with Clonezilla, then I will use GPated Live to boot the computer and move all the partitions right of the WinRE partition (usually it is the leftmost partition) to the right, and then expand the WinRE partition, using again Disk Management.  My partition setup is more complex than usual as I dual-boot to Windows 10 and Debian.

      • #2632417

        I would not do anything, especially not using that convoluted method. Wait for MS to find a solution and then see what it does – Susan will let us know.

        cheers, Paul

        1 user thanked author for this post.
      • #2635217

        BE CAREFUL when trying to resize and move Linux Root Partitions (system partitions for Linux)! I not only had to repair GRUB for one Linux installation, on two others even that could not repair the damages.

        Linux experts almost all agree that trying to resize or move Linux ext4 partitions is very prone to errors and unrecoverable damages. Better to back up all data (and back up by imaging, not by cloning if you want to restore the whole system), then delete and recreate the ext4 partitions and reinstall GRUB where (and what size) you want those items to be.

        Other small partitions to the right of the C:/Windows partition may have functions for Windows, or they may not. The Linux GRUB Boot or EFI Boot Partitions can also be out there. Messing with those partitions can also cause irreparable damages to Linux booting.

        It is also not safe to try to resize or move purely data ext4 partitions. But if you also back up your Linux data to external drives, this is not a particularly important problem, as those partitions can be recreated and repopulated relatively easily.

        One Windows note: When I resized and moved my Windows 11 system partition, the ApplicationData Junction became exposed, and file copying and disk space usage reporting operations became muddled, with large occurrences of nested recursions of the ApplicationData “folder”. The problem with the junction was a security restriction, which is supposed to Deny Access to nearly all normal users.  This restriction was not preserved when the C:windows partition was resized or moved. (It was not pleasant wading through all of the online obfuscations about the ApplicationData Junction to figure out how to fix the issue. There’s a lot of misinformation drifting around out there on this topic.)

        Your mileage may vary.

        -- rc primak

    • #2632467

      Will, I decided to run the script from your repository for curiosity’s sake. Just a couple of weeks ago I did an clean reinstall of Win 11 on my NVME drive. Here’s the result.

      Recovery Partition path: \\?\GLOBALROOT\device\harddisk3\partition3\Recovery\WindowsRE
      WinRE is on disk 3 in partition 3
      Recovery Partition size: 202910 MB
      Recovery Partition free: 117682 MB

      Based on the size the WinRE partition is actually the OS partition. The partition number is also wrong. The OS is on partition 5, not 3 (counting the first partition as #1, I don’t remember the correct convention). Apparently there is no actual WinRE partition.

      Aomei PA lists the first partition as GPT, EFI system partition with 32 mb of 100 mb used. That’s not the RE partition is it? The next three partitions are 530 MB, 16 MB, and 1.85 GB in size with 0 MB used. The next two partitions are the OS and Data. There are no partitions beyond the data partition.

      Windows Update shows I’m up to date but I don’t see the WinRE update installed. What does that mean, if anything?

      Just thought I’d let you know in case this info helps someone figure this whole thing out!

      • #2632522

        @Mac E, you mention an NVMe, drive, and it looks like “reagentc /info” is saying the recovery partition is on disk 3. Disk numbering usually starts at 0, which I think means you have four or more drives? Were you inspecting the fourth drive with Aomei PA?

        FWIW I am not sure that KB5034441 applies to Windows 11–I’m not seeing it offered on the Win11 machines that I manage.

      • #2632527

        In Win11, the updates is built into the CU. KB5034441 applies to Win10.

        1 user thanked author for this post.
    • #2632478

      Based on the size the WinRE partition is actually the OS partition.

      Would you mind posting a screen capture of the Disk Management window for your PC?

    • #2632520

      This script is brilliant! Thanks for figuring all that out. I’ve just deployed it to several dozen machines through my RMM tool and can now see in my dashboard the WinRE status of each machine.

      In the RMM, I can quickly see the first line returned, then click it for more info. So I modified the script to print a summary on the first line.

      I was also interested in the Build number as requested by @lmacri, and thought I’d check whether KB5034441 (client) or KB5034439 (server) showed as installed. I stole the SPBuild logic from Jody MacKercher’s post that Susan reposted on the Master Patch List page. Here’s my modified version for anyone who is interested (as always, use at your own risk!):

      #Requires -RunAsAdministrator
      
      Clear-Host
      
      # Determine the location of the active recovery position
      $info = (reagentc /info)
      
      # Extract the status of the recovery partition from the REAgentC result
      $winrestat = ( $info | select-string "Windows RE status:\s+([^\r\n]+)");
      $winrestatus = $winrestat.Matches.groups[1].value.trim()
      
      If ($winrestatus -ne "Disabled") {
        # Extract the location of the recovery partition from the REAgentC result
        $winreloc  = ( $info | select-string "Windows RE location:\s+(([^\r\n]+)disk(\d+)\\partition(\d+)\\([^\r\n]+))");
        $winrepath = $winreloc.Matches.groups[1].value.trim()
        $winredisk = $winreloc.Matches.groups[3].value
        $winrepart = $winreloc.Matches.groups[4].value
      
        # Determine the size and available space in the recovery partition
        $winresizes = (Get-Volume -FilePath $winrepath | 
                      Select-Object SizeRemaining,Size )
        $winresize = [math]::Round($winresizes.Size/1MB)
        $winrefree = [math]::Round($winresizes.SizeRemaining/1MB)
      
        # Get the WinRE build version
        $winrebuild = (Get-WindowsImage -Imagepath ($winrepath + "\winre.wim") -Index 1).SPBuild
        
        # Check for hotfixes
        $KB5034441_installed = ((Get-HotFix -id KB5034441 -ErrorAction SilentlyContinue) -ne $null)
        $KB5034440_installed = ((Get-HotFix -id KB5034440 -ErrorAction SilentlyContinue) -ne $null)
        $KB5034439_installed = ((Get-HotFix -id KB5034439 -ErrorAction SilentlyContinue) -ne $null)
      
        # Output the information, starting with a one-line summary
        Write-Host "Recovery Partition (build $winrebuild) has $winrefree of $winresize MB free"
        Write-Host "Recovery Partition path: $winrepath"
        Write-Host "WinRE is on disk $winredisk in partition $winrepart"
        Write-Host "Recovery Partition size: $winresize MB"
        Write-Host "Recovery Partition free: $winrefree MB"
        Write-host "WinRE Build Number: $winrebuild"
        Write-Host "KB5034441 (Windows 10 patch) installed: $KB5034441_installed"
        Write-Host "KB5034440 (Windows 11 patch) installed: $KB5034440_installed"
        Write-Host "KB5034439 (Server 2022 patch) installed: $KB5034439_installed"
      } else {
        Write-Host "Recovery Partition is disabled. No further info available."
      }
      4 users thanked author for this post.
    • #2632526

      FWIW I am not sure that KB5034441 applies to Windows 11

      It does not – KB5034440 applies to Windows 11 and addresses the same matter.

      2 users thanked author for this post.
      • #2632534

        Ah okay, modifying the script accordingly.

        However, I’m not seeing KB5034440 on Windows 11 machines either.

        • #2632818

          Windows 11, version 21H2  <<< it only applies to that version.

          Susan Bradley Patch Lady/Prudent patcher

          2 users thanked author for this post.
          • #2632823

            Looks like I can no longer edit the script I posted yesterday, but my version now has this output on a Windows 10 22H2 machine:

            Recovery Partition (build 3920) has 176 of 995 MB free
            Recovery Partition path: \\?\GLOBALROOT\device\harddisk0\partition5\Recovery\WindowsRE
            WinRE is on disk 0 in partition 5
            Recovery Partition size: 995 MB
            Recovery Partition free: 176 MB
            WinRE Build Number: 3920
            KB5034441 (Windows 10 patch) installed: True
            KB5034440 (Windows 11 21H2 patch) installed: False
            KB5034439 (Server 2022 patch) installed: False

            And on a Windows 11 22H2 machine:

            Recovery Partition (build 3000) has 1313 of 2000 MB free
            Recovery Partition path: \\?\GLOBALROOT\device\harddisk0\partition5\Recovery\WindowsRE
            WinRE is on disk 0 in partition 5
            Recovery Partition size: 2000 MB
            Recovery Partition free: 1313 MB
            WinRE Build Number: 3000
            KB5034441 (Windows 10 patch) installed: False
            KB5034440 (Windows 11 21H2 patch) installed: False
            KB5034439 (Server 2022 patch) installed: False
    • #2632539

      How do I upload an image from my PC? All is see is the option to link a URL.

      • #2632552

        How do I upload an image from my PC? All is see is the option to link a URL.

        Got it figured out!.

    • #2632541

      Will, here they are. Interestingly Aomei PA shows one more partition than does Window Computer Management!

      1 user thanked author for this post.
    • #2632551

      @Mac E, you mention an NVMe, drive, and it looks like “reagentc /info” is saying the recovery partition is on disk 3. Disk numbering usually starts at 0, which I think means you have four or more drives? Were you inspecting the fourth drive with Aomei PA?

      FWIW I am not sure that KB5034441 applies to Windows 11–I’m not seeing it offered on the Win11 machines that I manage.

      Yeah, I find it interesting. It definitely is seen as the fourth drive, Drive 3, by Windows. Win11 OS is on that drive and it is the boot drive. Why it’s not Drive 0 I can’t answer!

      You’ll see in my screenshots above that Disk 2 partitions O: and P: are labeled NVME. That’s because they are clones of C: and D: before I did the reinstall so I just added Clone to the label.

      I never really paid attention to it before but Windows does not identify what type of drive connection there is. For the NVME the Bios shows M2_1, HWinfo shows NVME, and Win Disk Mgmt and Aomei PA don’t show a connection type at all.

      • #2632556

        Size-wise, your 1.85GB partition “must” be the  recovery partition but why it shows as “Unallocated” in Disk Management… strange. Here for comparison purposes is a basic Win11 laptop as received from Lenovo. All I did was shrink C: and create D:.

        Win11-partitions

         

        1 user thanked author for this post.
    • #2632560

      I just remembered, unallocated space is not a partition.

      • #2632922

        I just remembered, unallocated space is not a partition.

        According to my latest views of Aomei PA and Disk Mgmt it looks like the unallocated space is indeed counted as a partition.

    • #2632623

      your 1.85GB partition “must” be the  recovery partition

      I suspect there is no recovery partition.

      cheers, Paul

      1 user thanked author for this post.
    • #2632658

      I suspect there is no recovery partition.

      That’s my suspicion as well. When REAgentC identifies the boot drive as the recovery partition, we observe no physical recovery partition with Disk Management. But that’s strictly empirical based on observation of a very tiny number of machines – we have yet to find documentation or other proof that this is the case.

      1 user thanked author for this post.
    • #2632667

      Windows Update shows I’m up to date but I don’t see the WinRE update installed. What does that mean, if anything?

      As near as I can tell, it just means there is no physical recovery partition. According to the documentation for REAgentC (see the section on the /enable option), you should find a winre.wim file in the \Windows\System32\Recovery folder.

      Is that the case?

      Why it’s not Drive 0 I can’t answer

      I’m speculating here, but I think drive numbering is driven by BIOS.

      • #2632686

        Yes, drive numbers are done by controller ports and are fixed in the BIOS. If you change port, by moving cables or NVMe slots, the drive number will change.

        cheers, Paul

        1 user thanked author for this post.
      • #2632757

        According to the documentation for REAgentC (see the section on the /enable option), you should find a winre.wim file in the \Windows\System32\Recovery folder.

        It seems that may no longer be true in all cases.

        On both of my Uncle’s Windows 10 22H2 PC’s reagentc /info showed his recovery partition was on the primary OS partition and winre.wim was located in C:\Recovery\WindowsRE not C:\Windows\System32\Recovery and there was no recovery partition on any of his drives.

        After using the reagentc /disable to disable WinRE, manually creating a separate recovery partition, and then using the reagentc /enable to reenable WinRE on both PC’s, it was moved to the new recovery partition and there’s now a ReAgentOld.xml file in C:\Recovery on both PC’s.

        BTW, even though recover mode worked just fine with winre.wim in the C:\Recovery\WindowsRE folder, KB5034441 failed to install on both his PC’s (even though there was plenty of “unused” space available on their OS partitions) until we created a separate recovery partition.

        1 user thanked author for this post.
    • #2632684

      Here is a simple CMD file to allow you to run PS1 scripts as admin, without changing Execution Policy.

      Place the CMD file and the PS1 file in a new temporary directory.
      Double click the CMD file and the PS1 will be run elevated.

      Note: do not put more than 1 PS1 file in the directory. The script will run all it finds (a fix for another day).

      cheers, Paul

      @for /f "tokens=*" %%x in ('dir /b "%~dp0*.ps1"') do if exist "%%~dpfx" powershell.exe -command start-process powershell -verb runas -argumentlist '-executionpolicy Bypass -file """%%~dpfx"""'
      
    • #2632760

      It seems that may no longer be true in all cases.

      In recent months, we’ve complained a lot about Microsoft’s poor documentation.

      1 user thanked author for this post.
      • #2632761

        And it seems to have only gotten worse over the past few years.

        Maybe when they got rid of their QA testers, they also got rid of their document maintainers?

    • #2632799

      Maybe when they got rid of their QA testers, they also got rid of their document maintainers?

      Documentation is a form of QA. Sometimes writing about a system or code in a human language provides clarity. If you can’t describe it, or if your description doesn’t make sense, something is usually wrong.

      3 users thanked author for this post.
      • #2632836

        Documentation is a form of QA. Sometimes writing about a system or code in a human language provides clarity. If you can’t describe it, or if your description doesn’t make sense, something is usually wrong.

        If so, that would imply that the ‘official QA’ documented answer to the WinRE partition resizing has been available since June 2023 for in-support operating systems listed under the article header.

        Reads like we were warned back then, albeit in small hidden print, only for MSFT to discover that partition positional layouts varied across different system configurations later in proceedings.
        I’m of the thought that it’s unlikely MSFT will re-issue a patch to replace/ supercede kb5034441 for W10.

        Windows - commercial by definition and now function...
        1 user thanked author for this post.
    • #2632826

      As near as I can tell, it just means there is no physical recovery partition. According to the documentation for REAgentC (see the section on the /enable option), you should find a winre.wim file in the \Windows\System32\Recovery folder.

      I don’t find a WinRE.wim file anywhere on my drives, no separate partition nor in C:\Recovery or C:\Windows\System32\Recovery folders. ReAgent.xml is the only file in the C:\Windows\System32\Recovery folder. There is an ReAgentold.xml file in the C:\Recovery folder. But WinRE exists somewhere because when I do the Shift-Restart sequence the Recovery window opens up.

      Here’s what is in the XML file.

      <?xml version=’1.0′ encoding=’utf-8′?>

      <WindowsRE version=”2.0″>
      <WinreBCD id=”{e7169deb-b1a2-11ee-ab51-b0aa8123f2d7}”/>
      <WinreLocation path=”\Recovery\WindowsRE” id=”0″ offset=”2661285888″ guid=”{103d103f-5858-9090-8081-828310111213}”/>
      <ImageLocation path=”” id=”0″ offset=”0″ guid=”{00000000-0000-0000-0000-000000000000}”/>
      <PBRImageLocation path=”” id=”0″ offset=”0″ guid=”{00000000-0000-0000-0000-000000000000}” index=”0″/>
      <PBRCustomImageLocation path=”” id=”0″ offset=”0″ guid=”{00000000-0000-0000-0000-000000000000}” index=”0″/>
      <InstallState state=”1″/>
      <OsInstallAvailable state=”0″/>
      <CustomImageAvailable state=”0″/>
      <IsAutoRepairOn state=”1″/>
      <WinREStaged state=”0″/>
      <OperationParam path=””/>
      <OperationPermanent state=”0″/>
      <OsBuildVersion path=”22621.1.amd64fre.ni_release.220506-1250″/>
      <OemTool state=”0″/>
      <IsServer state=”0″/>
      <DownlevelWinreLocation path=”” id=”0″ offset=”0″ guid=”{00000000-0000-0000-0000-000000000000}”/>
      <IsWimBoot state=”0″/>
      <NarratorScheduled state=”0″/>
      <ScheduledOperation state=”4″/>
      </WindowsRE>

      What’s interesting is the XML lists a WindowsRE folder, but I find no WindowsRE folder in my Win 11 OS partition. Other than that I don’t know enough about Windows to interpret the rest of the XML file.

       

       

       

      • #2632833

        I don’t find a WinRE.wim file anywhere on my drives, no separate partition nor in C:\Recovery or C:\Windows\System32\Recovery folders.

        I wouldn’t be surprised if these folders and files are flagged as System files, possibly Hidden too. Change your Explorer options to show both, or from an elevated command prompt:

        c:
        cd \
        dir WinRE.wim /as /s
      • #2632859

        But WinRE exists somewhere because when I do the Shift-Restart sequence the Recovery window opens up.

        Open an elevated Command Prompt and type

        reagentc /info

        and hit Enter.  That will display the location of Windows RE.

        Windows-RE

        Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
        We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
        We were all once "Average Users".

    • #2632845

      I don’t find a WinRE.wim

      I have WinRE.wim in C:\$WinREAgent\Backup

      $WinREAgent folder has been created on Jan.11 updates.

      1 user thanked author for this post.
    • #2632853

      I’m of the thought that it’s unlikely MSFT will re-issue a patch to replace/ supercede kb5034441 for W10.

      Remember, the KB5034441 update is connected to CVE-2024-20666, BitLocker Security Feature Bypass Vulnerability. That is not something Microsoft can ignore.

      This will be fixed.

      1 user thanked author for this post.
    • #2632872

      I wouldn’t be surprised if these folders and files are flagged as System files, possibly Hidden too. Change your Explorer options to show both, or from an elevated command prompt:

      c:
      cd \
      dir WinRE.wim /as /s

      Bingo! I had forgotten that the system attribute hides a file or folder. The winre.wim file is the system Recovery folder. It looks like when you invoke the recovery mode the wim file is deployed to a virtual boot drive in ram and is designated as X:. I found an Askwoody column that discusses this.

      As far as the issue of not enough space for the KB update that should not be the case on systems where WinRE is in a folder and not in a separate partition.

    • #2632878

      Open an elevated Command Prompt and type

      reagentc /info

      and hit Enter. That will display the location of Windows RE.

      Unless I’m mistaken this entire discussion started out with the understanding (assumption?) that WinRE was a separate partition, and when that partition couldn’t be identified we were stumped.

      I will say that WinRE can be either a partition or a folder in the OS. Who knows why Windows does one but not the other. Just now when I ran REagentC /info it shows the correct partition, 5, on drive 3. One of the unallocated space partitions shows up in Aomei PA but not Windows Computer Mgmt, so according to Win Mgmt the script output is wrong. But it’s correct according to Aomei PA.

      • #2632897

        I will say that WinRE can be either a partition or a folder in the OS.

        That is incorrect.  The file winre.wim may be found in a folder in the OS partition, but that is not the Windows RE.  Windows RE only functions from a separate partition, not from the OS partition.

        The Windows RE is a bootable partition with repair tools for a misbehaving Windows.  It boots into a Windows PE environment with Trusted Installer privileges.

        Unless I’m mistaken this entire discussion started out with the understanding (assumption?) that WinRE was a separate partition, and when that partition couldn’t be identified we were stumped.

        Windows Update was stumped if Windows RE is not enabled, because in that circumstance the location of the partition is unknown to the OS.  That’s one of the reasons the update would fail.  Not enough free space in the partition for the update is another reason it would fail.  Of course, and as always, there could be various and sundry other reasons that the update failed for other folks.

        But two definitive requirements are that the OS knows the location of the Windows RE partition (e.g. it is enabled), and the partition has enough free space to install the update to the Windows RE.

        Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
        We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
        We were all once "Average Users".

        1 user thanked author for this post.
    • #2632885

      Open an elevated Command Prompt and type

      reagentc /info

      and hit Enter. That will display the location of Windows RE.

      Unless I’m mistaken this entire discussion started out with the understanding (assumption?) that WinRE was a separate partition, and when that partition couldn’t be identified we were stumped.

      I will say that WinRE can be either a partition or a folder in the OS. Who knows why Windows does one but not the other. Just now when I ran REagentC /info it shows the correct partition, 5, on drive 3. One of the unallocated space partitions shows up in Aomei PA but not Windows Computer Mgmt, so according to Win Mgmt the script output is wrong. But it’s correct according to Aomei PA.

      This is an interesting find/conclusion–that maybe it’s supposed to be in a folder on C:. Which seems a bit odd if the purpose is to recover the copy of Windows installed on C:

      If your drive is like mine, there is a 16MB Reserved partition. It is not unallocated; it is counted as a partition. I have no clue why it’s not shown in Disk Management–it’s not on my machine either–but diskpart from the command line will show it. See my screen shots in this post above.

      1 user thanked author for this post.
    • #2632918

      That is incorrect. The file winre.wim may be found in a folder in the OS partition, but that is not the Windows RE. Windows RE only functions from a separate partition, not from the OS partition.

      The Windows RE is a bootable partition with repair tools for a misbehaving Windows. It boots into a Windows PE environment with Trusted Installer privileges.

      Then why do I not find a partition identified as recovery by either Computer Mgmt or Aomei PA? There are three blank partitions on my disk 3, all with 0 bytes used and all between the EFI partition #1 and C: drive. There are no partitions beyond C: and D:. Yet I can boot up into a recovery mode using Shift+Restart. When I go to the command prompt option in the recovery mode I see an entire Windows PE installation running on drive X:. It is labeled MININT-xxxxxx and as a Boot drive.

      What I believe happens is when you do the Shift-Restart option Windows creates the Windows Recovery OS from the winRE.wim file and stores it in ram and then restarts and boots from the ram image.

      • #2632944

        Yet I can boot up into a recovery mode using Shift+Restart. When I go to the command prompt option in the recovery mode I see an entire Windows PE installation running on drive X:. It is labeled MININT-xxxxxx and as a Boot drive.

        Thanks!  This sent me down a rabbit hole and has peaked my curiosity.  I’ll start a new thread, because what I’ve stumbled into is relevant, but not particularly pertinent to this one.

        Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
        We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
        We were all once "Average Users".

        1 user thanked author for this post.
    • #2632920

      Hey Y’all,

      Here’s an updated version of Shawn Hall’s script that Will Fastie and I have been working on for the last couple of days. We wanted to make it cover as many possibilities as we could come up with. We also added some additional information on the Windows Version the WinPE is based on as requested by @Imacri.

      I’d also like to shout out to @bbearren for testing the script on his Hardened Windows an admittedly off beat configuration.

      <#+----------------------------------------------------------+
        | PowerShell script to determine location, size, and free  |
        | space of the active recovery partition.                  |
        | From Shawn Hall, Patch Management Group at Google Groups |
        | Updated 26-29 Jan. 2024 by Bruce Kriebel and Will Fastie |
        | Script must be run fron a elevated (admin) environment   |
        +----------------------------------------------------------+
      #>
      
      Function Get-AdminStatus {
      
        $identity =
           [Security.Principal.WindowsIdentity]::GetCurrent()
        $principal =
           New-Object Security.Principal.WindowsPrincipal $identity
      
        If (-NOT ($principal.IsInRole(
            [Security.Principal.WindowsBuiltinRole]::Administrator)))
          {"User"}
        Else
          {"Administrator"}
      
      } # -----------  End Function Get-AdminStatus -----------------
      
      Clear-Host
      If ( (Get-AdminStatus) -ne "Administrator") {
        "Please rerun as Administrator!"
        Read-Host -Prompt "Press Enter to Continue..."
        Exit
      }
      
      # Determine the location of the active recovery position
      $info = (reagentc /info)
      
      # Extract the status of the recovery partition from the
      # REAgentC result
      $winrestat   = ( $info |
         select-string "Windows RE status:\s+([^\r\n]+)");
      $winrestatus = $winrestat.Matches.groups[1].value.trim()
      Write-Host "Recovery Partition is $winrestatus"
      
      If ($winrestatus -ne "Disabled") {
      
         # Extract the location of the recovery partition from the
         # REAgentC result
         $Pattern   = "Windows RE location:\s+(([^\r\n]+)disk(\d+)\\" +
                      "partition(\d+)\\([^\r\n]+))"
         $winreloc  = ( $info | select-string $Pattern )
         $winrepath = $winreloc.Matches.groups[1].value.trim()
         $winredisk = $winreloc.Matches.groups[3].value
         $winrepart = $winreloc.Matches.groups[4].value
      
         # Determine size & available space in the recovery partition
         $winresizes = (Get-Volume -FilePath $winrepath |
                       Select-Object SizeRemaining,Size )
         $winresize = [math]::Round($winresizes.Size/1MB)
         $winrefree = [math]::Round($winresizes.SizeRemaining/1MB)
      
         #Get Windows Version Info
         $x = Dism /Get-ImageInfo /ImageFile:\\?\GLOBALROOT\device\harddisk$winredisk\partition$winrepart\Recovery\WindowsRE\winre.wim /index:1
         $Vers    = $x | Select-String "Version :"
         $Vers    = ($vers.Tostring().split(":"))[1].Trim()
         $Edition = $X | Select-String "Edition :"
         $Edition = ($Edition.Tostring().split(":"))[1].Trim()
      
         # Output the information
         "Recovery Partition path: $winrepath"
         "WinRE is on disk $winredisk in partition $winrepart"
         "Recovery Partition size: $winresize MB"
         "Recovery Partition free: $winrefree MB"
         "Windows Edition        : $Edition"
         "Windows Version        : $vers"
      
      }
      
      Else {
      
        $x = Get-Volume
      
        $RecPartExists = $False
      
        For ($cnt = 0; $cnt -lt $x.count; $cnt++) {
      
           If ( (($x[$($cnt)].DriveType)       -eq "Fixed") -and
                ($Null -eq (($x[$($cnt)].DriveLetter))    ) -and
                (($x[$($cnt)].FileSystemLabel) -eq ""     ) -and
                (($x[$($cnt)].FileSystem)      -eq "NTFS" ) ) {
             $RecPartExists = $True
           } # End If
      
        } #End For
      
        If (-Not $RecPartExists) {
             "No Recovery Partition Exists on Drive 0!"
             "Unless you have moved it to another drive..."
             "`tNo Recovery Partition Exists!"
        } #End If
      
      } #End Else
      

      I’ve also posted a copy of the script in a Zip file on my shared OneDrive folder.

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

      1 user thanked author for this post.
      • #2632926

        …We also added some additional information on the Windows Version the WinPE is based on as requested by @Imacri.

        Hi RetiredGeek / Will Fastie:

        Kudos for the revised script in post # 2632920. Here’s the output from my Win 10 Pro v22H2 machine (KB5034441 WinRE update installed 16-Jan-2024 with no errors).

        Win-10-Pro-v22H2-Revised-PowerShell-Script-With-Version-After-KB5034441-30-Jan-2024

        My only suggestion is that when you “#Get Windows Version Info” of the winre.win image (in my case 10.0.19041) that you also retrieve the ServicePack Build and Service Pack Level (and perhaps even the Modified date/time). My images in post # 2631957 show that it was a change from ServicePack Build 3562 (modified 12-Oct-2023) to ServicePack Build 3920 (modified 16-Jan-2024) that confirmed that KB5034441 had installed correctly.
        ———–
        Dell Inspiron 5584 * 64-bit Win 10 Pro v22H2 build 19045.3930 * Firefox v122.0.0 * Microsoft Defender v4.18.23110.3-1.1.23110.2 * Malwarebytes Premium v4.6.8.311-1.0.2249 * Macrium Reflect Free v8.0.7783

      • #2632951

        I’d also like to shout out to @bbearren for testing the script on his Hardened Windows an admittedly off beat configuration.


        @RetiredGeek
        , the script testing didn’t reveal this mystery:

        Windows RE — Curiouser and Curiouser

        Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
        We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
        We were all once "Average Users".

    • #2632923

      The script errors out with the #End Else statement.

      • #2632924

        Mac E,

        Are you sure you copied it all?

        I just ran it again on 2 machines and also copied the code from the post and it works as it should.

        Could you post the error messages please.

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

      • #2633062

        The script errors out with the #End Else statement.

        Hi Mac E:

        Are you starting PowerShell with Administrator rights?

        I also have issues running .ps1 files on my system. Typically, if I double click on a .ps1 file the PowerShell interface will launch but immediately closes without displaying any output.

        However, if I right-click on Windows PowerShell from my Start button program menu, select Run as Administrator, copy and paste RetiredGeek’s script in post # 2632920 into the PowerShell interface, and hit Enter then the code runs correctly.

        Win-10-Pro-v22H2-Start-PowerShell-As-Adminstrator-31-Jan-2024
        ————-
        Dell Inspiron 5584 * 64-bit Win 10 Pro v22H2 build 19045.3930 * Firefox v122.0.0 * Microsoft Defender v4.18.23110.3-1.1.23110.2 * Malwarebytes Premium v4.6.8.311-1.0.2249 * Macrium Reflect Free v8.0.7783

    • #2632929

      Mac E,

      Are you sure you copied it all?

      I just ran it again on 2 machines and also copied the code from the post and it works as it should.

      Could you post the error messages please.

      I think what’s happening is I expected a single group of lines giving the result of the script. Now I see it returns responses all the way through. It ends at the end of the last line. I hit Enter and that is when the error comes up. It looks like you may need to add a clean end to the script to return focus to the PS prompt.

      • #2632936

        Mac E,

        Are you sure you copied it all?

        I just ran it again on 2 machines and also copied the code from the post and it works as it should.

        Could you post the error messages please.

        I think what’s happening is I expected a single group of lines giving the result of the script. Now I see it returns responses all the way through. It ends at the end of the last line. I hit Enter and that is when the error comes up. It looks like you may need to add a clean end to the script to return focus to the PS prompt.

        For a script like this (with variables, if/then/else logic, etc.), it’s better to paste it into Notepad, save it as a .ps1 file, then run it from a PowerShell window by typing .\script.ps1. It’s not meant to be pasted directly at a PowerShell prompt. Do that and you’ll get all the output at once.

    • #2632931

      It sure looks to me like Reagentc is inconsistent in how it counts partitions. This script says it’s in Partition 3. When I run Reagentc /info it says WinRE is in Partition 5. So one time two unallocated partitions get counted, and then the next time they don’t.

    • #2632933

      Mac E,

      The error message indicates that the error is at line 1 character 1 with the text Else {

      That would indicate that you may not have copied the whole script…

      As to your second post the WinRE partition can be located anywhere as @bbearren can attest. The script is designed to find the WinRE partition and report on it.

      I’ve uploaded the script already in a .ps1 file on my shared OneDrive you can download that file and try running it. See post above for link.

      May the Forces of good computing be with you!

      RG

      PowerShell & VBA Rule!
      Computer Specs

    • #2632935

      For what it’s worth, I have two PCs and a laptop, all running Win 11. On my second desktop, named Moble Home Hag, Win 11 was installed by the computer shop on an SSD. I later added an NVME drive and cloned the OS to it and deleted it off the SSD. There is a partition identified as Recovery on the SSD, but it seems to not be used. There is no winre.wim on the current C: drive that I can find. When I boot into recovery and go to advanced the only options are UEFI change and Reset. Command prompt is not available.

      I installed Win 11 on my laptop in dual boot mode with Win 10 about the same time I installed it my primary desktop, Hagatha. There is no recovery partition that I can identify as tied into Win11. There is one that is still tied to Win10. I see all the usual Recovery mode options when I enter it from Win 11.

      If I remember correctly when I did the clean reinstall of Win 11 about 2 weeks ago on Hagatha I deleted all the partition associated with the boot drive. The resulting configuration is what is shown in the screenshot above.

      My speculation, based on my limited exposure with my three machines is Microsoft is migrating from having the recovery partition separate from the OS partition and moving it to a folder within Windows. MS doesn’t identify my machine as needing the WinRe update. Could it that when I reinstalled Win 11 and it downloaded updates in that process the WinRE update was included? So what I’m suggesting is that the WinRE update process is still a fluid process that hasn’t had all its kinks worked out.

    • #2632965

      I’ve uploaded the script already in a .ps1 file on my shared OneDrive you can download that file and try running it. See post above for link.

      I can’t run it. I get an error about scripts being prohibited on this machine. I find all kinds of circular discussion about powershell script execution policy but no straightforward simple command line to enable running of scripts. I have no need nor desire to learn the intricacies of running Powershell. If you can give me a script to change the policy so the script will run, I’ll try running it. Otherwise I’m going to forget it. As an alternative can someone point exactly where I need to make a change in Group Policy so scripts will run.

      I’m beginning to get the feeling trying to use Windows for simple tasks is like using a rail car to haul sand for a kid’s sandbox!

      1 user thanked author for this post.
      • #2632994

        All you need to do is download my RunScriptAsAdmin CMD file above and it will sort out the issue for you.

        1. Create a new temporary folder.
        2. Save the RG’s script as Recovery.PS1 to the new folder. Any name will do but it must end in PS1.
        3. Extract RunScriptAsAdmin from the zip file to the new folder.
        4. Double click on RunScriptAsAdmin.CMD.

        cheers, Paul

      • #2633052

        In Powershell, started as Administrator, enter: set-executionpolicy remotesigned

        Select: Yes to All when prompted.

        Don’t forget to Unblock the .ps1 file in File Explorer properties.

        May the Forces of good computing be with you!

        RG

        PowerShell & VBA Rule!
        Computer Specs

    • #2633053

      but no straightforward simple command line to enable running of scripts.

      You make a good point.

      Traditional batch files are easily run from the command line (CMD), which can be run with elevated privileges if necessary. The only requirement is that you run the batch file from the folder containing it. And it is not necessary to attach the extension; if your file is named mycmd.bat, you only need to enter mycmd. Naturally, you can use a full path to run a batch file from another folder. If your batch file does not require parameters, you can navigate to its folder using File Explorer and double-click it.

      Sadly, none of that works for PowerShell scripts, and I think Microsoft made a mistake by not allowing the richer and more powerful PS to behave more like batch files. That’s why far fewer people know little or nothing about PowerShell.

      The closest Microsoft came was the PowerShell ISE, which is available in Windows by default. It provides a hospitable environment for working with PS scripts. Although there are no plans to remove PS ISE from Windows, it supports PS only up to version 5.1; 7.4 is the current version.

      To replace ISE for newer versions of PowerShell, Microsoft built an extension for Visual Studio Code. As with ISE, VSC/PS provides a command line, an editing environment, and an execution environment. VSC can be run with elevated privileges, so it’s a snap to launch VSC, load the desired script, and run it. (It’s what I use.)

      Not many people know about that, which is remarkable because the extension was originally published in November 2015.

      Admittedly, PowerShell’s real target is Windows administrators, who always crave automation for complex procedures that are well beyond the capabilities of batch files.

      1 user thanked author for this post.
      • #2633121

        Naturally, you can use a full path to run a batch file from another folder. If your batch file does not require parameters, you can navigate to its folder using File Explorer and double-click it.

        Sadly, none of that works for PowerShell scripts,

        You can’t run PowerShell scripts with a full path or from file explorer?

        Although there are no plans to remove PS ISE from Windows, it supports PS only up to version 5.1; 7.4 is the current version.

        But only PowerShell 5.1 is included with Windows?

    • #2633161

      You can’t run PowerShell scripts with a full path or from file explorer?

      When I double-click a .ps1 file, I get a warning about installing an app which is not in the App Store. If I click Install Anyway, the file is opened in NotePad. I suppose I could finagle that and get it to work, but I’d like that to work out of the box. Meanwhile, using VSC is more convenient for me.

      But only PowerShell 5.1 is included with Windows?

      That’s a very good question. I believe the answer is yes. Launch PowerShell and enter Get-Host | Select-Object Version to see the version.

      I think a problem here is that even though PS is now at 7.4, there is a backward compatibility issue that will probably require 5.1 to remain an active Windows component for some time. To work with 7, I needed to load the PS extension.

      PowerShell is now cross-platform. See Install PowerShell on Windows, Linux, and macOS. This is the page you’ll see when you visit https://aka.ms/pscore6, the site that is mentioned when you run PowerShell on Windows.

    • #2633170

      When I double-click a .ps1 file, I get a warning about installing an app which is not in the App Store. If I click Install Anyway, the file is opened in NotePad. I suppose I could finagle that and get it to work, but I’d like that to work out of the box.

      Seems expectations can go both ways here. If you double-click on an .exe, it runs. But if you double-click on .doc/.xls/.txt, the file opens. Sometimes I’ve double-clicked a .cmd file, wanting to view its contents, only to have it run and potentially modify things. I’d rather err on the side of double-click = view (also for php, vbs, etc.). I’m fine with the right-click > Run with PowerShell option. (It would be nice to also have right-click > Run with PowerShell as Administrator.) In fact, now that you mention it, I’m changing the Properties of .ps1 files to open with Notepad++, my preferred PowerShell editor.

    • #2633171

      Here is a simple CMD file to allow you to run PS1 scripts as admin, without changing Execution Policy.

      Place the CMD file and the PS1 file in a new temporary directory.
      Double click the CMD file and the PS1 will be run elevated.

      Note: do not put more than 1 PS1 file in the directory. The script will run all it finds (a fix for another day).

      cheers, Paul

      @for /f "tokens=*" %%x in ('dir /b "%~dp0*.ps1"') do if exist "%%~dpfx" powershell.exe -command start-process powershell -verb runas -argumentlist '-executionpolicy Bypass -file """%%~dpfx"""'
      

      No luck, unless “Recovery Partition is Enabled” is all there is supposed to be! The PS window closes before I can see if there is any other output from the script. The script needs a command to keep the window open upon completion, I think.

      • #2633298

        Here is a version that keeps the PS window open. Edit the CMD file in Notepad and replace the command.

        cheers, Paul

        @for /f "tokens=*" %%x in ('dir /b "%~dp0*.ps1"') do if exist "%%~dpfx" powershell.exe -command start-process powershell -noexit -verb runas -argumentlist '-executionpolicy Bypass -file """%%~dpfx"""'
    • #2633172

      Notepad++, my preferred PowerShell editor.

      Give VSC with the PS extension a try. I’d be surprised if you didn’t like it.

      2 users thanked author for this post.
    • #2633188

      OK, getting back to the original discussion of this thread. After checking some more on my three machines, one of which has two installations of Win 11 I will emphatically state that MS has transitioned the Recovery system from a dedicated partition to a folder in the Windows installation. I just checked the temp Win 11 installation you can see in the screenshot above.  I installed it about two weeks ago. There is no EFI partition, probably because that installation is booted from a boot manager on  another drive. There is no Recovery partition on drive 0. There is a WindowsRE folder in C:\Recovery which contains the boot.sdi, ReAgent.xml, and winre.wim files. Reagentc /info points to that folder. All of my Win 11 installations show WinRE in a folder, not in a dedicated partition.

      Is it possible that a number of the failures in installing the WinRE update are not the result of undersized recovery partitions but rather not finding such partition in the first place? I have BitLocker turned off on all my drives. Is that why I’m not seeing my Windows installations showing I need that update.

    • #2633193

      Windows 11, version 21H2  <<< it only applies to that version.

      That’s why I don’t see it as a needed update. My Win 11 is 23H2.

    • #2633485

      Attached is a modified version of @RetiredGeeks script that displays the results without closing when run directly from Windows Explorer.

      Depending on exactly what it finds, it’ll display one of the following popups when it’s run.

      DisplayedScriptWindows

      Simply extract the .ps1 file and run it.

      Note: as @RetiredGeek indicated above, you must have enabled “set-executionpolicy remotesigned” in powershell and Right-click the file and select “Run as Administrator” for it to work.

      2 users thanked author for this post.
      • #2633510

        Attached is a modified version of @RetiredGeeks script that displays the results without closing when run directly from Windows Explorer…

        Hi n0ads:

        Thanks for adding the winre.wim version info to the script. I cheated a bit by launching Windows PowerShell (v5.1.19041.3930 on my Win 10 machine) with Administrator rights, opening your .ps1 script in Notepad, copying and pasting the script into the PowerShell interface, and hitting “Enter” to run the script. Here’s my output:

        PowerShell-v5_1_19041_3930-n0ads-Modified-Script-Date-Truncated-01-Feb-2024

        I noticed a minor glitch for the Modified date on my system. The year is truncated (i.e., the output is “16-Jan-2” instead of “16-Jan-2024”), and I’m guessing that has something to do with the fact that my region is Canada (English) and Settings | Time & Language | Region | Regional Format | Short Date is set to dd-mmm-yyyy (see attached image).
        ————-
        Dell Inspiron 5584 * 64-bit Win 10 Pro v22H2 build 19045.3930 * Firefox v122.0.0 * Microsoft Defender v4.18.23110.3-1.1.23110.2 * Malwarebytes Premium v4.6.8.311-1.0.2249 * Macrium Reflect Free v8.0.7783

        1 user thanked author for this post.
        • #2633624

          Thanks for the heads up!

          I initially had the code truncate the date to the first 8 characters “assuming” everyone’s short date would be either dd/mm/yy or mm/dd/yy format; my bad!

          I’ve updated the code so it strips the time off the right side of the variable instead and, using your dd-mmm-yyyy format on my PC, here’s what it now displays.

          CorrectDatesDisplayed

          Also, in line with Will’s below suggestion, I changed the Create-Form function name to New-Form

          Attached is the new version of the script.

          • #2633689

            Hi n0ads:

            Your modified script attached to post # 2633624 is an improvement but still truncates the last digit off my year with PowerShell v5.1.19041.3930. I tried copying and pasting the script into an elevated PowerShell interface as well as running the .ps1 script from File Explorer with an elevated PowerShell interface as instructed in Method 1 of Diane Poremski’s Executing PowerShell Scripts FAQ and Tips & Tricks and got the same result with both methods.

            PowerShell-v5_1_19041_3930-n0ads-Modified-2-Script-Date-Truncated-02-Feb-2024

            Just an FYI that the full date/time field is displayed as “16-Jan-2024 – 9:46:17 AM” in the second image in my post # 2631957 when I display my winre.wim info in an elevated command prompt using a Dism /Get-ImageInfo command. Would your script be more robust if you showed the full date/time in your PowerShell output instead of trying to strip off the time portion?
            ————-
            Dell Inspiron 5584 * 64-bit Win 10 Pro v22H2 build 19045.3930 * Firefox v122.0.0 * Microsoft Defender v4.18.23110.3-1.1.23110.2 * Malwarebytes Premium v4.6.8.311-1.0.2249 * Macrium Reflect Free v8.0.7783

    • #2633492

      Attached is a modified version of @RetiredGeeks script

      There is a tiny and highly technical semantic error in the script that does not prevent it from running, but throws a warning error when the script is loaded in VSC/PS. The function Create-Form is technically illegal because it does not use an “approved verb.” This means that  “Create” is not supposed to be used.

      “New” is an appropriate approved verb. See Approved Verbs for PowerShell Commands.

      VSC/PS is very good at finding this sort of thing.

      1 user thanked author for this post.
    • #2633715

      but still truncates the last digit off my year

      I “assumed” the hours would always be in HH format (with a leading 0 when it’s less 2 digits) when I set how much to strip off the right side of the date.

      If it’s in H format (where there’s no leading 0) it’ll strip off the last digit of the year like it did for you.

      Would your script be more robust if you showed the full date/time in your PowerShell output instead of trying to strip off the time portion?

      Again, I “assumed” most users would only be interested in the date the winre.wim was modified not the exact date & time.

      However, since you bought it up…

      I created two different versions of the script.

      One that displays only the date (corrected so it’ll leave the last digit of the year if the hour is a single digit) and one that displays the full date & time.

      Download the attached zip file and extract whichever version suits your personal preference.

      2 users thanked author for this post.
      • #2633726

        Hi n0ads:

        Kudos! Both .ps1 scripts in the zipped file attached to post # 2633715 are now running correctly in an elevated PowerShell v5.1.19041.3930 interface with Administrator rights.

        Date only:

        PowerShell-v5_1_19041_3930-n0ads-Modified-3-Script-Date-Only-02-Feb-2024

        Date and Time:

        PowerShell-v5_1_19041_3930-n0ads-Modified-3-Script-Date-and-Time-02-Feb-2024
        ————-
        Dell Inspiron 5584 * 64-bit Win 10 Pro v22H2 build 19045.3930 * Firefox v122.0.0 * Microsoft Defender v4.18.23110.3-1.1.23110.2 * Malwarebytes Premium v4.6.8.311-1.0.2249 * Macrium Reflect Free v8.0.7783

        • #2633943

          Hi @lmacri,
          I’m confused about the term “used space” here in the image above. The message from @n0ads’ script says “Used Space: 990 MB”

          Elsewhere, in #2628970, your image from Fsutil shows “Total{bytes}: 990 MB”

          Isn’t Total space the sum of used space & free space (i.e., total space = used space + free space)?

          So, is your Total space (1087 MB) = 990 MB (used space) + 97 MB (free space)?

          Or is your Total space (990 MB) = 893 MB (used space) + 97 MB (free space)?

          In this equation, total space is synonymous with used space, only when free space is 0. But, you have 97 MB free space.

          So, what does “used space” in @n0ads’ script message mean, when fsutil says your total space is 990 MB??

          • #2633959

            I’m confused about the term “used space” here in the image above. The message from @n0ads’ script says “Used Space: 990 MB” Elsewhere, in #2628970, your image from Fsutil shows “Total{bytes}: 990 MB”

            Hi WCHS:

            I tested by running these commands for my entire C:\drive. For example, my C:\ drive is 223 GB in total and currently has ~ 109 GB used + 113 GB free space.

            Win-10-Pro-v22H2-C-Drive-Properties-Free-and-Used-Disk-Space-02-Feb-2024

            When I run the command fsutil volume diskfree C: in an elevated command prompt it shows I have 223.4 GB total and 113.8 GB free …

            Win-10-Pro-v22H2-Command-Prompt-fsutil-volume-diskfree-02-Feb-2024

            … which is identical to what I see when I run the Get-Volume -DriveLetter C command in an elevated PowerShell console (i.e., which is similar to the Get-Volume command used in n0ads’ PowerShell script for finding the size of the Win RE partition).

            Win-10-Pro-v22H2-PowerShell-Get-Volume-02-Feb-2024

            If I run Get-Volume in an elevated PowerShell console to see all my partitions :

            Win-10-Pro-v22H2-PowerShell-Get-Volume-All-Partitions-02-Feb-2024

            So n0ads would have to confirm, but I assume that when their zipped PowerShell scripts attached to post # 2633715 report that the “Used space” for my WinRE partition (disk0 \ partition4) is is 990 MB I assume that is the total disk space used by that partition, which includes 893 MB used and 97 MB free.
            ————-
            Dell Inspiron 5584 * 64-bit Win 10 Pro v22H2 build 19045.3930 * Firefox v122.0.0 * Microsoft Defender v4.18.23110.3-1.1.23110.2 * Malwarebytes Premium v4.6.8.311-1.0.2249 * Macrium Reflect Free v8.0.7783

            1 user thanked author for this post.
        • #2634098

          I’m confused about the term “used space” here in the image above. The message from @n0ads’ script says “Used Space: 990 MB”

          I assume that is the total disk space used by that partition

          @lmacri is right, in my original scripts, Used space = Total partition size.

          To avoid further confusion, I’ve updated both scripts so they display Total, Free and Used (Total – Free) like this.

          NewScriptDisplay

          To avoid possible issues with how it displays on PC’s using different regional settings, I also changed the “Modified” value so it uses a PC’s default date/time format.

          Modified versions attached.

          3 users thanked author for this post.
          • #2634104

            When you modify the script, would it be possible to include the date (like 230203) or a version # (v1.3, v2.2, etc) in the .zip file name to help identify which is newer?
            Thanks.

            5 users thanked author for this post.
            • #2634280

              Actually, I did use a different name for each of the .zip files.

                v1 = GetRecoveryPartionInfomodified.zip

                v2 = GetRecoveryPartionInfomodified-2.zip

                v3 GetRecoveryPartionInfotwo-versions.zip

                v4 GetRecoveryPartionInfotwo-versions-MODIFIED.zip

              But I didn’t change the names of the actual .ps1 files they contain.

              If I make further modifications to the scripts, I’ll add a version number to all the files.

              Thanks for the suggestion!

              2 users thanked author for this post.
            • #2634302

              Version control goes a long way in my book, having worked with ammendments, component updates, methodologies and engineering change notes in company specifications brings back some memories 😐

              Windows - commercial by definition and now function...
          • #2634185

            To avoid further confusion, I’ve updated both scripts so they display Total, Free and Used (Total – Free)… I also changed the “Modified” value so it uses a PC’s default date/time format.

            Hi n0ads:

            Nicely done.   Just confirming that both .ps1 scripts in the zipped file attached to your 03-Feb-2024 post # 2634098 run correctly in an elevated PowerShell v5.1 console (i.e., launched with “Run as Administrator”) on my system.

            Date Only:

            PowerShell-v5_1_19041_3930-n0ads-Modified-4-Script-Date-Only-03-Feb-2024

            Date & Time:

            PowerShell-v5_1_19041_3930-n0ads-Modified-4-Script-Date-and-Time-03-Feb-2024
            ————-
            Dell Inspiron 5584 * 64-bit Win 10 Pro v22H2 build 19045.3930 * Firefox v122.0.0 * Microsoft Defender v4.18.23110.3-1.1.23110.2 * Malwarebytes Premium v4.6.8.311-1.0.2249 * Macrium Reflect Free v8.0.7783

            1 user thanked author for this post.
    • #2633761

      FWIW, both scripts work with PS 7.4.1 with admin rights.

       

      --Joe

      1 user thanked author for this post.
      • #2633770

        FWIW, both scripts work with PS 7.4.1 with admin rights.

        I’m running 7.4, and both work for me except the resulting dialog box is only large enough to display “OK”.

        <<Edit>> I updated to PS 7.4.1, and the dialog box looks right, now.

        Always create a fresh drive image before making system changes/Windows updates; you may need to start over!
        We all have our own reasons for doing the things that we do with our systems; we don't need anyone's approval, and we don't all have to do the same things.
        We were all once "Average Users".

        1 user thanked author for this post.
    • #2633793

      How do I manually download and install the WinRE update? I have a Win 10 machine the install failed on. I find a recovery partition with the label “Dell SSD Recovery” and wonder if that is why it failed. The partition is 14 Gb in size so that obviously that can’t be the reason. But the update is not in the MS catalog and I don’t find a way through Windows Update to download and install it. I wanted to see if the partition name was the cause of the install failure. Windows Update says my machine is up to date.

      • #2633796

        Run the script. It will show which partition is your Recovery partition.

        Please upload your disk management screen shot.
        OEM usually add their own recovery partition which is separate from Windows OS recovery partition.

        KB5034441 can’t be downloaded manually.

        If Recovery partition is too small KB5034441 will fail
        If you don’t have Recovery partition KB5034441 will fail
        If you don’t use Bitlocker you don’t need KB5034441.

        If you run Jan. updates and KB5034441 failed no harm done.
        You can hide the update until Microsoft may fix it.

        1 user thanked author for this post.
        • #2633809

          How do I manually download and install the WinRE update?

          Run the script. It will show which partition is your Recovery partition… KB5034441 can’t be downloaded manually.

          Which script do you mean? There are so many scripts in this topic. Their results are not the same. Some have problems and some do not. And whether it runs successfully or not can depend on what version of PS you have on your machine. So whose script are you referring to?

          As for finding the KB, the Master Patch list dated Jan 10 has some suggestions on where you might find it on your device.

          I wish there were some guidance on whether the dust has settled on Powershell scripts to find out about the WinRE partition and WinRE.wim. As far as I can tell at this point, the one in #2633715, whose results are shown in # 2633726 is “the script”.

          How to run “the script” is another matter. @lmacri give some hints <here>:

          I cheated a bit by launching Windows PowerShell (v5.1.19041.3930 on my Win 10 machine) with Administrator rights, opening your .ps1 script in Notepad, copying and pasting the script into the PowerShell interface, and hitting “Enter” to run the script.

          and <here>.

          I tried copying and pasting the script into an elevated PowerShell interface as well as running the .ps1 script from File Explorer with an elevated PowerShell interface as instructed in Method 1 of Diane Poremski’s Executing PowerShell Scripts FAQ and Tips & Tricks and got the same result with both methods.

          Maybe, there’s a better one that will run on ANY machine, no matter how it’s configured?

    • #2633939

      Run the script. It will show which partition is your Recovery partition. Please upload your disk management screen shot. OEM usually add their own recovery partition which is separate from Windows OS recovery partition.

      It’s plain to see which is the recovery partition. There is no separate Windows recovery partition.

      KB5034441 can’t be downloaded manually.

      If Recovery partition is too small KB5034441 will fail

      If you don’t have Recovery partition KB5034441 will fail

       

      Based on what I see in the directories, and the content of screwball named .xml files, I would say any WinRE that doesn’t conform to MS prescribed structure will fail with the update.

      This machine was a Win 7 machine that I upgraded to Win 10, and then later replaced the OEM hard drive with an SSD. I added the SSD in the volume names. But why on earth did Windows 10 install not wipe out the old OEM recovery stuff and create its own proper recovery system? MS looks to have treated the entire Windows Recovery system as an afterthought programmed by inexperienced junior “wet behind the ears” programmers.

      If you don’t use Bitlocker you don’t need KB5034441. If you run Jan. updates and KB5034441 failed no harm done. You can hide the update until Microsoft may fix it.

      For me, and probably millions of everyday users, this is the best bit of info with regard to this issue I have read. Now all I have to do is find out how to hide updates. I wasn’t aware this could be done.

       

    • #2633942

      I’m of the opinion that all of you guys’ efforts to resolve the problems of updating WinRE are to a great extent wasted efforts. Not because it’s not important, and not because you don’t know what you are doing, quite the opposite, but MS has implemented the recovery system in as many different variations as there are shapes of wood in a campfire wood pile while expecting them to all be cut to one size using a single tool configuration.

       

    • #2633945

      I’m of the opinion that all of you guys’ efforts to resolve the problems of updating WinRE are to a great extent wasted efforts.

      I don’t agree. Microsoft is the reason this is so difficult to understand. But it’s essential to understand due to the update errors that threw a wrench into January. On behalf of all our readers, I asked Microsoft for an explanation and got the “no further comment” response.

      What else is there to do but experiment?

      I appreciate the effort that has been put into trying to grasp this. It has informed us all.

      6 users thanked author for this post.
    • #2633972

      I have read. Now all I have to do is find out how to hide updates.

      You can use Microsoft’s Wushowhide, WUmgr, WUmt.. tools to hide any updates and unhide when ready to install.

      https://www.askwoody.com/2024/quick-video-to-showcase-how-to-hide-kb5034441/

      If you run a Pro version you have settings to control updates using GPEdit

      https://www.askwoody.com/forums/topic/2000016-guide-for-windows-update-settings-for-windows-10/

    • #2633975

      Mac E wrote: I’m of the opinion that all of you guys’ efforts to resolve the problems of updating WinRE are to a great extent wasted efforts.

      I don’t agree. Microsoft is the reason this is so difficult to understand. But it’s essential to understand due to the update errors that threw a wrench into January. On behalf of all our readers, I asked Microsoft for an explanation and got the “no further comment” response. What else is there to do but experiment?

      I apologize for discrediting the value of your work. I recognize now the landscape of PC users and administrators that you primarily serve is much wider than just SOHO users such as myself, therefore the level of responsibility for finding answers to issues such as this is much greater for your constituency than for the average home user.

       

    • #2634016

      I apologize for discrediting the value of your work.

      I didn’t take it that way. I look at this forum topic as pulling back the curtains on what should have been a well-documented feature of Windows.

      SOHO users

      That happens to be the majority of our readers. See Who are you? from one year ago.

      2 users thanked author for this post.
    Viewing 57 reply threads
    Reply To: PowerShell script to test partition sizes

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: