Search code examples
windowspowershelldiskwindows-server

Powershell: Extract physical disk properties based on a logical drive name or a filepath


Went through few similar queries, but could not a get a related solution as per my requirement.

Here is what I want:

I am writing a powershell script that, given a logical drive name (or a filepath), should be able to return me its underlying physical drive info like serial number, manufacturer etc.

I can get these details from Get-Disk or Get-PhysicalDisk. I see logical volume details from Get-Volume. But how do I correlate these two results to filter out results based on a specific logical volume or path (like get serial number of physical disk for the logical drive D:)

Any help is appreciated.

This is what I have tried until now:

My logical driver for which I want to get disk details:

PS C:\Users\Administrator> Get-Volume -FilePath U:\

DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining  Size
----------- ------------ -------------- --------- ------------ ----------------- -------------  ----
U           New Volume   NTFS           Fixed     Healthy      OK                     19.91 GB 20 GB

Get-Disk has all the information I need:

PS C:\Users\Administrator> Get-Disk | Select Manufacturer, SerialNumber, UniqueId

Manufacturer SerialNumber UniqueId
------------ ------------ --------
3PARdata     SGH622X73L   60002AC0000000000E006A980001AB73
3PARdata     SGH622X73L   60002AC0000000000E006A990001AB73
3PARdata     SGH622X73L   60002AC0000000000E006E9D0001AB73
3PARdata     SGH622X73L   60002AC0000000000E006E9E0001AB73
3PARdata     SGH622X73L   60002AC0000000000E006E9F0001AB73
3PARdata     SGH622X73L   60002AC0000000000E006EA00001AB73

My problem is, how do I filter out which of the above listing belongs to my logical volume U:\ ?


Solution

  • @zett42's link worked for me. Posting it here again:

    get-partition -DriveLetter U | get-disk