Search code examples
powershelldriveremovable-storage

Get a partition name with PowerShell


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?


Solution

  • You can use WMI, I guess:

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