Querying disks with the PowerShell Get-Disk cmdlet

You can use the PowerShell Get-Disk cmdlet to query disk drives within or attached to a PC running the Microsoft Windows operating system. E.g.:

PS C:\Users\Public> Get-Disk

Number Friendly Name Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                             Style
------ ------------- -------------                    ------------         -----------------      ---------- ----------
0      ST3320418AS               9VMNNJDN             Healthy              Online                  298.09 GB MBR
4      Generic- C... 058F63626421                     Healthy              No Media                      0 B RAW
6      Generic- M... 058F63626423                     Healthy              No Media                      0 B RAW
3      Generic- S... 058F63626420                     Healthy              No Media                      0 B RAW
5      Generic- S... 058F63626422                     Healthy              No Media                      0 B RAW
1      Lexar USB ... AA58ZF9FJCCALAOA                 Healthy              Online                   14.92 GB MBR
2      WD My Pass... WXP1A27034VH                     Healthy              Online                  931.48 GB GPT


PS C:\Users\Public>

The aboue output shows me that the Windows 10 system on which I ran the command has an internal Seagate disk drive with a model number of ST3320418AS; I can tell it is a Seagate drive since Seagate starts the model number of its drives with "ST". The serial number of the drive is 9VMNNJDN and it isn't experiencing problems, i.e., it is "healthy". I can also see the drive is 300 GB in size and and uses a Master Boot Record (MBR) partition scheme rather than a GUID Partition Table (GPT) as is used with drive number 2 on the system, which is a Western Digital (WD) drive.

If I wanted information only on one particular drive, I could get information on the internal drive by specifying its drive number, which is "0". Or, if I wanted information on just specific drives on the system I could specify them as comma-separated drive numbers as shown below.

PS C:\Users\Public> Get-Disk 0

Number Friendly Name Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                             Style
------ ------------- -------------                    ------------         -----------------      ---------- ----------
0      ST3320418AS               9VMNNJDN             Healthy              Online                  298.09 GB MBR


PS C:\Users\Public> Get-Disk 0, 2

Number Friendly Name Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                             Style
------ ------------- -------------                    ------------         -----------------      ---------- ----------
0      ST3320418AS               9VMNNJDN             Healthy              Online                  298.09 GB MBR
2      WD My Pass... WXP1A27034VH                     Healthy              Online                  931.48 GB GPT


PS C:\Users\Public>

In the above output, some values may be truncated with the truncation indicated by three dots, e.g., for drive 2. I can see the truncated information as well as more details by piping the output to Format-List.

PS C:\Users\Public> Get-Disk 2 | Format-List


UniqueId           : USBSTOR\DISK&VEN_WD&PROD_MY_PASSPORT_25E1&REV_1019\575850314132373033345648&0:THELMA-LOU
Number             : 2
Path               : \\?\usbstor#disk&ven_wd&prod_my_passport_25e1&rev_1019#575850314132373033345648&0#{53f56307-b6bf-1
                     1d0-94f2-00a0c91efb8b}
Manufacturer       : WD
Model              : My Passport 25E1
SerialNumber       : WXP1A27034VH
Size               : 931.48 GB
AllocatedSize      : 1000170586112
LogicalSectorSize  : 512
PhysicalSectorSize : 4096
NumberOfPartitions : 1
PartitionStyle     : GPT
IsReadOnly         : False
IsSystem           : False
IsBoot             : False



PS C:\Users\Public>

Or, if I just want a specific value or values I can specify the desired value(s) as shown below by piping the output to select.

Learning Windows PowerShell
Learning Windows PowerShell
1x1 px

PS C:\Users\Public> Get-Disk 2 | select Model

Model
-----
My Passport 25E1


PS C:\Users\Public> Get-Disk 2 | select Model, SerialNumber

Model            SerialNumber
-----            ------------
My Passport 25E1 WXP1A27034VH


PS C:\Users\Public>

Or if I wanted to see just the disk manufacturered by Seagate, I could use the following command.

If I want to only see the drives that use the MBR or GPT partitioning scheme, I can pipe the output of Get-Disk to Where-Object as shown below.



PS C:\Users\Public> Get-Disk | Where-Object {$_.PartitionStyle -eq 'MBR'}

Number Friendly Name Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                             Style
------ ------------- -------------                    ------------         -----------------      ---------- ----------
0      ST3320418AS               9VMNNJDN             Healthy              Online                  298.09 GB MBR
1      Lexar USB ... AA58ZF9FJCCALAOA                 Healthy              Online                   14.92 GB MBR


PS C:\Users\Public> Get-Disk | Where-Object {$_.PartitionStyle -eq 'GPT'}

Number Friendly Name Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                             Style
------ ------------- -------------                    ------------         -----------------      ---------- ----------
2      WD My Pass... WXP1A27034VH                     Healthy              Online                  931.48 GB GPT


PS C:\Users\Public>

If I only want to see a list of those connected to the system by a Universal Serial Bus (USB) connection, I can specify the bus type as shown below.

PS C:\Users\Public> Get-Disk | Where-Object {$_.Bustype -Eq 'USB'}

Number Friendly Name         Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                                     Style
------ -------------         -------------                    ------------         -----------------      ---------- ----------
4      Generic- Compact F... 058F63626421                     Healthy              No Media                      0 B RAW
6      Generic- MS/MS-Pro    058F63626423                     Healthy              No Media                      0 B RAW
3      Generic- SD/MMC       058F63626420                     Healthy              No Media                      0 B RAW
5      Generic- SM/xD Pic... 058F63626422                     Healthy              No Media                      0 B RAW
1      Lexar USB Flash Drive AA58ZF9FJCCALAOA                 Healthy              Online                   14.92 GB MBR
2      WD My Passport 25E1   WXP1A27034VH                     Healthy              Online                  931.48 GB GPT


PS C:\Users\Public>

You can chain pipes to narrow down the output and show full details for the drives selected as shown below.

PS C:\Users\Public> Get-Disk | Where-Object {$_.Bustype -Eq 'USB'} | Where-Object {$_.PartitionStyle -Eq 'Gpt'} | format-list


UniqueId           : USBSTOR\DISK&VEN_WD&PROD_MY_PASSPORT_25E1&REV_1019\575850314132373033345648&0:THELMA-LOU
Number             : 2
Path               : \\?\usbstor#disk&ven_wd&prod_my_passport_25e1&rev_1019#575850314132373033345648&0#{53f56307-b6bf-11d0-94f2
                     -00a0c91efb8b}
Manufacturer       : WD
Model              : My Passport 25E1
SerialNumber       : WXP1A27034VH
Size               : 931.48 GB
AllocatedSize      : 1000170586112
LogicalSectorSize  : 512
PhysicalSectorSize : 4096
NumberOfPartitions : 1
PartitionStyle     : GPT
IsReadOnly         : False
IsSystem           : False
IsBoot             : False



PS C:\Users\Public>

If you wish to use PowerShell to determine which drive will be used to boot the system you can specify the "IsBoot" parameter. E.g.:

PS C:\Users\Public> Get-Disk | Where-Object {$_.IsBoot -eq 'True'}

Number Friendly Name         Serial Number                    HealthStatus         OperationalStatus      Total Size Partition
                                                                                                                     Style
------ -------------         -------------                    ------------         -----------------      ---------- ----------
0      ST3320418AS                       9VMNNJDN             Healthy              Online                  298.09 GB MBR


PS C:\Users\Public> Get-Disk | Where-Object {$_.IsBoot -eq 'True'} | format-list


UniqueId           : SCSI\DISK&VEN_&PROD_ST3320418AS\4&D20E9B0&0&000000:THELMA-LOU
Number             : 0
Path               : \\?\scsi#disk&ven_&prod_st3320418as#4&d20e9b0&0&000000#{53f56307-b6bf-11d0-94f2-00a0c91efb8b}
Manufacturer       :
Model              : ST3320418AS
SerialNumber       :             9VMNNJDN
Size               : 298.09 GB
AllocatedSize      : 320072933376
LogicalSectorSize  : 512
PhysicalSectorSize : 512
NumberOfPartitions : 3
PartitionStyle     : MBR
IsReadOnly         : False
IsSystem           : True
IsBoot             : True



PS C:\Users\Public>

Related articles:

  1. Show all drives from Windows command prompt
  2. Determining S.M.A.R.T disk drive status from a command prompt
  3. Viewing Partition Information on a Windows System
  4. Obtaining the model number and serial number for a HDD from the command line
  5. Using wmic to get disk drive information

References:

  1. Get-Disk
    Microsoft TechNet