Look up hard disk information with PowerShell

Martin Brinkmann
May 28, 2019
Updated • Nov 15, 2019
Windows
|
6

Windows PowerShell is quite powerful when it comes to looking up hard disk information. While you may look up some information in Windows directly, e.g. in Disk Management, or by using third-party programs like Hard Disk Validator, Disk Checkup, or DiskBoss, using PowerShell is a quick and easy option as well.

Hard disks are essential on Windows as they store operating system data and user data. The devices don't last forever, and a hard disk failure can easily lead to all sorts of issues including data loss if backups are not available (or corrupt).

PowerShell comes with several commands that return information about connected internal and external storage devices.

You may start a new PowerShell console by opening Start, typing Powershell, and selecting the item from the list of results. The commands don't require elevation to run.

Option 1: Retrieve general information

display disk information windows powershell

The command: get-wmiobject -class win32_logicaldisk

Run the command get-wmiobject -class win32_logicaldisk to look up core information about each connected hard drive. The command returns drive letters and types, the overall size and free space in bytes, and the volume name.

Drive type uses a numerical code:

  • 0 -- Unknown
  • 1 -- No Root directory
  • 2 -- Removable Disk
  • 3 -- Local Disk
  • 4 -- Network Drive
  • 5 -- Compact Disc
  • 6 -- Ram Disk

You may use filters to display only select drive types, e.g. Get-WmiObject -Class Win32_logicaldisk -Filter "DriveType =4" to display network drives only.

Option 2: Retrieve hard drive properties

wmic diskdrive get

The command: wmic diskdrive get

The core command wmic diskdrive get needs to be followed by one or multiple properties.

The command wmic diskdrive get Name,Model,SerialNumber,Size,Status returns names, model types, serial numbers, the overall size in bytes, and the status for all connected hard drives.

Other properties that you may retrieve include InstallDate, InterfaceType, FirmwareRevision, DefaultBlockSize, CompressionMethod, Capabilities, Availability, LastErrorCode, or PowerManagementCapabilities.

Just add, replace, or remove any property from the command to create a custom one.

Closing Words

The PowerShell commands may be useful in certain situations. Apart from use in scripts, you may use them to quickly look up the status of all drives, look up serial numbers or error codes, or capabilities.

PowerShell

For Windows

Some users may prefer to use a program with a graphical interface like Crystal DiskInfo for that, and that is perfectly fine as well.

Summary
Look up hard disk information with PowerShell
Article Name
Look up hard disk information with PowerShell
Description
Find out how to display information about connected hard drives and disks using the PowerShell console of the Windows operating system.
Author
Publisher
Ghacks Technology News
Logo
Advertisement

Tutorials & Tips


Previous Post: «
Next Post: «

Comments

  1. Anonymous said on April 28, 2021 at 7:57 pm
    Reply

    This also doesn’t deal with Individual physical disks which make up a Raid Array albeit the subject suggests it does.

  2. Gilles said on May 29, 2019 at 9:40 am
    Reply

    A full powershel version :
    Get-PhysicalDisk | select Model, FriendlyName, SerialNumber, Size, BusType, MediaType, OperationalStatus|Format-Table

  3. Trelfar said on May 28, 2019 at 3:55 pm
    Reply

    Any command that calls WMIC isn’t really ‘using PowerShell’ as WMIC is an independent binary that can be used from CMD or any other command processor, and the output is simple text cannot be manipulated in PowerShell without first parsing it into objects.

    As an earlier commenter mentioned, Get-PhysicalDisk, along with Get-Disk, are native PowerShell commands that do the heavy lifting for you and return their data in actual PowerShell objects.

  4. Robert O. said on May 28, 2019 at 2:12 pm
    Reply

    Get storage disk volume size:

    WMIC LogicalDisk Where DriveType=3 Get DeviceID, VolumeName, Size, FreeSpace /Format:Value

    Get current processor usage:

    WMIC CPU Get Name, LoadPercentage /Format:Value

    Get memory size and usage:

    WMIC ComputerSystem Get TotalPhysicalMemory /Format:Value
    WMIC OS Get FreePhysicalMemory /Format:Value

  5. Constance said on May 28, 2019 at 1:16 pm
    Reply

    One should be warned however that WMI may sometimes report wrong serial numbers for disk drives, as some people reported here : https://social.technet.microsoft.com/Forums/scriptcenter/en-US/0333dd28-3207-4df8-85c3-7ff540f98464/wmi-disk-serial-number?forum=ITCG

  6. Taomyn said on May 28, 2019 at 12:49 pm
    Reply

    That’s not really “the Windows Powershell” (just a nod to remove the “the” at the start of the article) – it’s just calling WMI directly which you can do from a plain CMD prompt.

    What you really want to be doing is using this:

    Get-PhysicalDisk | FL

    Much easier to deal with within a PS script.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.