CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

PowerShell – How to retrieve storage volumes details?

The PowerShell command “Get-Volume” is used to get the storage volume(s) details on the system. By default, it returns the information about all volumes on all partitions, and on all connected disks on the system.

We can also retrieve information about specific volumes by applying the required filters.

Here are a few examples of how the “Get-Volume” command can be used:

The below command will display the information of all volumes on the system.

PS C:\> Get-Volume

DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining      Size
----------- ------------ -------------- --------- ------------ ----------------- -------------      ----
            Recovery     NTFS           Fixed     Healthy      OK                      1.84 GB   2.38 GB
C           OSDisk       NTFS           Fixed     Healthy      OK                     87.16 GB 235.05 GB

We can use the “-DriveLetter” parameter to filter the details for the specific volume or mount point. Below command will display the information of the volume with the drive letter “D”.

PS C:\> Get-Volume -DriveLetter D

DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining     Size
----------- ------------ -------------- --------- ------------ ----------------- -------------     ----
D           EXTDisk-211  FAT32          Removable Healthy      OK                     12.08 GB 15.22 GB

Have you observed the difference in the above results? The first one displays the results of the fixed storage volumes. And the second one displays the result of the Removable volume “D”. By checking the DriveType field values we can figure out whether the particular drive is removable or not.

If the particular volume is not identified, the PowerShell Get-Volume cmdlet with throw the error message. For example, we removed the removable storage volume and attempt to access it and received the below error:

PS C:\> Get-Volume D
Get-Volume : No MSFT_Volume objects found with property 'DriveLetter' equal to 'D'.  Verify the value of the
property and retry.
At line:1 char:1
+ Get-Volume D
+ ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (D:Char) [Get-Volume], CimJobException
    + FullyQualifiedErrorId : CmdletizationQuery_NotFound_DriveLetter,Get-Volume

 

[..] David

PowerShell – How to retrieve storage volumes details?

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top