Jump to content

(How to) Look up hard disk information with PowerShell


Karlston

Recommended Posts

Look up hard disk information with PowerShell

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.

 

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

 

Source: Look up hard disk information with PowerShell (gHacks - Martin Brinkmann)

Link to comment
Share on other sites


  • Views 719
  • Created
  • Last Reply

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...