Homepage 5 How-to Articles 5 How to Get a PC Hard Drive Information with Powershell

How to Get a PC Hard Drive Information with Powershell

Manage remote endpoints, deploy software and patches with a robust cloud-based Action1 RMM solution. Sign up to Action1 to use RMM tools free forever on up to 100 endpoints.

March 20, 2020

This article describes a way to get hard drive and partitions information using Windows PowerShell.

In Windows operating systems there are various ways to obtain information about disks and partitions, for example, you can use the Disk Management utility with a graphical interface or the command-line utility diskpart.

Get Disk Drives Name, Model, Interface Type, Size and Serial Number Using Powershell

You can get hard drive and partitions information using the Powershell cmdlets of the Storage module. A list of all cmdlets of the Storage module can be obtained by running the Windows PowerShell console and running the command:

Get-Command -Module Storage

Get hard drive information powershell. Show list of all cmdlets Storage module

The main cmdlets with which you can find out general information about disks and partitions:

  • Get-PhysicalDisk allows you to get information about physical disks, device characteristics.
  • Get-Disk display disk information at the logical level of the operating system.
  • Get-Partition show partition information on all drives.
  • Get-Volume display volume information on all disks.

So, to get information about physical disks, start the command:

Get-PhysicalDisk

Get information about physical disks

To get disk information at a logical level, run the command:

Get-Disk

Get hard drive information powershell. Get disk information at a logical level

Run the following command to display information about partitions on all disks:

Get-Partition

find out information about partitions on all disks

To find out information about volumes on all disks, run the command:

Get-Volume

Get hard drive information powershell. Find out information about volumes on all disks

Next, we consider how to improve the received information in terms of visual perception. To do this, you can remove unnecessary information and add only necessary, such as the type of drive and disk layout, as well as change the width of the table columns.

To do this, using the Format-Table cmdlet, display the desired properties in the table, aligning the columns to the width of the content.

For example, display the device number, model, drive type, bus type, and size, to do this, run the command:

Get-PhysicalDisk | ft -AutoSize DeviceId,Model,MediaType,BusType,Size

display the device number, model, drive type, bus type, and size

As you can see in the screenshot above, the Size column is displayed in bytes.

When you run Get-DiskGet-PhysicalDisk cmdlets without parameters, the Total Size column and the size in gigabytes are displayed, but if you run cmdlets with parameters, the property list contains the only Size in bytes.

To display the size in gigabytes, run the command:

Get-PhysicalDisk | ft -AutoSize DeviceId,Model,@{Name="Size, Gb"; Expression={$_.Size/1Gb}}

Get hard drive information powershell. Display the size in gigabytes

Also, the size value can be rounded to the nearest integer using the data type [int], the command will look like this:

Get-PhysicalDisk | ft -AutoSize DeviceId,Model,@{Name="Size, Gb"; Expression={[int]($_.Size/1GB)}}

size value rounded to the nearest integer

You can also apply Format-Table to Get-Disk cmdlet, for example, display the number, name, size, and disk layout style, to do this, run the command:

Get-Disk | Format-Table -AutoSize Number,FriendlyName,Size,PartitionStyle

Get hard drive information powershell. Apply Format-Table to Get-Disk cmdlet

Here the Size column also displays the size in bytes but using division as in the example above, you can get the size in gigabytes, to do this, run the command:

Get-Disk | Format-Table -AutoSize Number,FriendlyName,@{Name="Size, Gb"; Expression={[int]($_.Size/1GB)}}

Size column displays the size in bytes

Let’s look at examples for Get-Partition cmdlet, for example, display all sections of disk 0, for this, run the command:

Get-Partition -DiskNumber 0

Get hard drive information powershell. Display all sections of disk 0

To display section C information, run the command:

Get-Partition -DriveLetter C

Get hard drive information powershell. Display section C information

And as an example for Get-Volume cmdlet, display information about volume C, to do this, run the command:

Get-Volume -DriveLetter C

display information about volume C

Consider Using Action1 to Show Disk Drives if:

  • You need to perform an action on multiple computers simultaneously.
  • You have remote employees with computers not connected to your corporate network.

Action1 RMM is a solution for cloud patch management, software deployment, remote desktop, IT asset inventory, and endpoint management.

Related Articles

How To Delete User Profiles Remotely with PowerShell

When a user logs onto the computer for the first time (not via the network to access shared folders or printers), Windows creates a user profile. Among its contents are the NTUSER.DAT file (user profile settings), user-specific folders (My Documents, Desktop, etc.),...

How to Uninstall Programs With Standard Windows Tools

UThis tutorial for new users details where to add and remove Windows 10 programs, the quickest way to get to this Control Panel component, and more information on how to properly uninstall Windows 10 programs and applications from your computer. In fact, when compared...

How to Shutdown Computers via Powershell Remotely

It is logical that most people will always use graphic windows and a mouse to complete work on the computer, this is correct since it is simpler and faster, but there are a number of cases when you, as an advanced user or a system administrator, are simply obliged to...

About Action1 RMM

Action1 is a cloud-based IT solution for remote monitoring and management, patching, and remote support.

Try Action1 Free RMM on 100 endpoints with no functionality limitations or expiration!

0 Comments

Submit a Comment

Your email address will not be published.