Get a partition name with PowerShell

Phil picture Phil · Oct 12, 2012 · Viewed 12.3k times · Source

I have a flash drive which I formatted so that the volume label on the drive is "PHILIP".

enter image description here

I am using Get-PSDrive H -PSProvider FileSystem to determine if the drive is plugged in, however I would really like to determine if the drive is plugged in by the volume label, i.e. Get-PSDrive -VolumeLabel PHILIP -PSProvider FileSystem. Of course the VolumeLabel parameter does not exist so this doesn't work.

Is there a way to list the drives in a computer by volume name?

Answer

Joey picture Joey · Oct 12, 2012

You can use WMI, I guess:

Get-WMIObject Win32_Volume | ? { $_.Label -eq 'PHILIP' }