robert
robert

Reputation: 3726

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 diskart. Is there a Powershell command for this? It would be much easier to parse the object based output than the one from diskpart. I have tried get-volume but the EFI partition is not shown.

Upvotes: 0

Views: 3175

Answers (2)

Tom Galvin
Tom Galvin

Reputation: 901

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: https://en.wikipedia.org/wiki/EFI_system_partition

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.

Upvotes: 4

Christian Quast
Christian Quast

Reputation: 85

You can try Get-PSDrive cmdlet if you haven't already.

get-psdrive | where{$_.name -like "[A-Z]"}

Upvotes: 0

Related Questions