How do I find the EFI partition on a Dynamic disk using PowerShell?

59 Views Asked by At

Normally when looking for the EFI-partition using PowerShell you can use

Get-Disk | where IsBoot | Get-Partition |
  where GptType -eq '{c12a7328-f81f-11d2-ba4b-00a0c93ec93b}'

However, neither Get-Disk or Get-Partition works with Dynamic Disks.

It seems that WMI/CIM doesn't provide any easy means of locating EFI-partitions.

Is there a way to find the EFI-partition on Dynamic Disks using PowerShell with out resorting to bcdedit.exe or diskpart.exe?

I did find these links, but really...

Unfortunatly, this example from the CodeProject is missing data that I need.
And since I have no idea about the BcdStore object model, I don't know how to retrive additional imformation.

$mem = Get-StaticBcdStore | Open-Store "" | 
  Open-Object "{b2721d73-1db4-4c62-bf78-c548a880142d}"

$dev = $mem |
  Get-Element -Type ([BcdLibraryElementTypes]::Device_ApplicationDevice) |
    Get-Device

$dev.Properties_ | ConvertTo-Json -Depth 5
[
    {
        "Value":  "",
        "Name":  "AdditionalOptions",
        "IsLocal":  true,
        "Origin":  "BcdDeviceData",
        "CIMType":  8,
        "Qualifiers_":  [
                            {

                            }
                        ],
        "IsArray":  false
    },
    {
        "Value":  2,
        "Name":  "DeviceType",
        "IsLocal":  true,
        "Origin":  "BcdDeviceData",
        "CIMType":  19,
        "Qualifiers_":  [
                            {

                            }
                        ],
        "IsArray":  false
    },
    {
        "Value":  "\\Device\\HarddiskVolume2",
        "Name":  "Path",
        "IsLocal":  true,
        "Origin":  "BcdDevicePartitionData",
        "CIMType":  8,
        "Qualifiers_":  [
                            {

                            }
                        ],
        "IsArray":  false
    }
]

Edit 1: Added example from CodeProject

1

There are 1 best solutions below

1
ersati On

try this way

$efiPartitions = Get-WmiObject -Namespace "Root\CIMv2" -Query "SELECT * FROM Win32_DiskPartition WHERE Type = 'GPT: C12A7328-F81F-11D2-BA4B-00A0C93EC93B'"

foreach ($partition in $efiPartitions) {
     Write-Host "Disk $($partition.DiskIndex), Partition $($partition.DeviceID) is an EFI partition."
}