robert robert - 1 year ago 115
PowerShell Question

Find the volume letter of EFI partition

I am writing an interactive script and I need the volume letter of the EFI partition. It could happen that there is no letter assigned, in this case I will assign one to it. Since I do not know any method to detect it automatically (please tell me if it is possible), I have decided to list volumes and ask the user the Volume number.
The only command which lists it is the

list volume
command from
. Is there a Powershell command for this? It would be much easier to parse the object based output than the one from
. I have tried
but the EFI partition is not shown.

Answer Source

You could use this command to get the drive letter through the partition, rather than the volume:

get-partition | where-object {$_.GptType -eq "{C12A7328-F81F-11D2-BA4B-00A0C93EC93B}"} | select-object -first 1 DriveLetter

Where {C12A7328-F81F-11D2-BA4B-00A0C93EC93B} is the GUID for the EFI System Partition in the GPT:

If you then want to play around with the EFI System Partition object, use this command:

get-partition | where-object {$_.GptType -eq "{C12A7328-F81F-11D2-BA4B-00A0C93EC93B}"}

Which will get all partitions visible to the system which are ESP partitions - of which there should only be one.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download