System hacks: Display disk information with PowerShell command

Although we can view some basic information about disks through Windows Disk Manager, I am afraid that Disk Manager is not enough if we want to get more in-depth information about disk parameters. At this point, we can quickly view all the various parameters of the disk by using some simple PowerShell commands.

1. Display general information about the disk

First, right-click the Start button and select the PowerShell option to launch into the PowerShell console. Then enter the following command.

Get-Wmiobject -Class Win32_logicaldisk

This command allows you to view basic information about the disks attached to the machine. The information returned includes: drive number and type, total size and free space in bytes, and volume name (Figure 1).

1923A-YPXX-1

We can also use the filter parameter “-Filter “DriveType =n”” to display only the selected drive type, e.g.

Get-WmiObject -Class Win32_logicaldisk -Filter “DriveType =3”

This command above displays information about local drives only (Figure 2).

1923A-YPXX-2

The n in the parameter format is the driver type, the actual use is to use the numeric code instead of.

0 — Unknown

1 — No Root directory

2 — Removable Disk

3 — Local Disk

4 — Network Drive

5 — Compact Disc

6 — Ram Disk (RAM disk)

2. Flexible display of disk property information

With the “wmic diskdrive get” command, we can retrieve disk properties in a more flexible way. This core command needs to be followed by one or more parameters (separated by a comma), including the following basic parameters.

Name, Model, SerialNumber, Size, Status

Name, Model, SerialNumber, Size, and Status return information about the name, model, serial number, total size (in bytes), and status of all connected disks, respectively (Figure 3).

1923A-YPXX-3

In addition, other property parameters that can be retrieved include: InstallDate, InterfaceType, FirmWareRevision, DefaultBlockSize, CompressionMethod Capabilities, Availability, LastErrorCode, or PowerManagementCapabilities.

We can create custom disk property display commands by simply adding or replacing property parameters to the basic commands mentioned above.

Extended reading: Users who are not used to operating in a command mode can use third-party programs (e.g. Crystal Disk Info, Hard Disk Validator, Disk Checkup or DiskBoss software) to complete the display of disk information under the graphical interface.

QQ图片20210420165237

Leave a Comment