- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to get the disk information using PowerShell?
To get the Windows disk information using PowerShell, we can use the WMI command or the CIM class command.
With the WMI command,
Gwmi Win32_LogicalDisk
With the CIM instance method,
Get−CimInstance Win32_LogicalDisk
You can see both the outputs are identical. Let’s use one of them.
DeviceID DriveType ProviderName VolumeName Size FreeSpace -------- --------- ------------ ---------- ---- --------- C: 3 53317988352 44027125760 D: 5 HRM_SSS_X64FREE_EN-US_DV5 3694962688 0 E: 3 Temporary Storage 10734268416 10238513152
Now there are different drive types associated with Windows and they each have an identical number. For example, Drive Type ‘3’ mentions the logical disk. The other types are as below.
2 = "Removable disk"
3="Fixed local disk"
4="Network disk"
5 = "Compact disk"
Here, we will filter only logical system disks. For that, we can use the below command.
Get−CimInstance Win32_LogicalDisk | where{$_.DriveType −eq '3'}
Output
DeviceID DriveType ProviderName VolumeName Size FreeSpace -------- --------- ------------ ---------- ---- --------- C: 3 53317988352 44027023360 E: 3 Temporary Storage 10734268416 10238513152
The above size is displayed in bytes. You can convert it to GB using an expression. Use the below command, to convert the Size and FreeSpace into GB.
Get−CimInstance Win32_LogicalDisk | where{$_.DriveType −eq '3'} ` | Select DeviceID, DriveType,VolumeName, @{N='TotalSize(GB)';E={[Math]::Ceiling($_.Size/1GB)}}, @{N='FreeSize(GB)';E={[Math]::Ceiling($_.FreeSpace/1GB)}} | ft −AutoSize
Output
DeviceID DriveType VolumeName TotalSize(GB) FreeSize(GB) -------- --------- ---------- ------------- ------------ C: 3 50 42 E: 3 Temporary Storage 10 10
- Related Articles
- How to get the disk performance using PowerShell?
- How to get the Azure VM disk encryption settings using PowerShell?
- How to get the Azure VM disk caching settings using PowerShell?
- How to format the disk using PowerShell?
- How to get the specific process(es) information using PowerShell?
- How to get service information with the WMI method using PowerShell?
- How to change the local disk name using PowerShell?
- How to retrieve specific file(s) information using Get-ChildItem in PowerShell?
- How to find the disk type of the Azure Availability set using PowerShell?
- How to get all the Get-Process properties using PowerShell?
- How to get the file extension using PowerShell?
- How to get the folder size using PowerShell?
- How to get the readonly files using Get-ChildItem in PowerShell?
- How to Get Windows features using PowerShell?
- How to get mapped drives using PowerShell?

Advertisements