Updated by

Tracy King

Updated on April 26, 2024

Many Windows users wish to examine their disk space using PowerShell, but they might find the process perplexing. This tutorial is designed to present multiple methods for checking disk space with PowerShell, along with an alternative tool to display disk usage.

Sure, please provide the text that needs to be translated.

⏱️Duration: 5-10 minutes
?Goal: Check disk space using a PowerShell script on Windows computers
?Tools:

Check Disk Space using Powershell

When to Check Disk Space with PowerShell

Here are a few examples of specific situations or symptoms that might prompt you to check your computer's disk space using PowerShell:

    • The disk becomes full without any apparent reason
    • The computer system runs slowly or frequently freezes
    • Unable to install new applications or updates
    • Cannot save or open files
    • Files or apps take a long time to load
    • Low disk space alerts

If you've encountered any of the scenarios mentioned above, you can refer to the tutorial in the upcoming section to check disk space using PowerShell.

How to Check Disk Space in PowerShell [With Images]

There are several methods to check disk space in PowerShell. This section will present three commonly used approaches to examine your disk space with PowerShell commands. These methods are relatively simpler and practical for Windows users.

Method 1: Check Disk Space via the Get-Volume Command in PowerShell

Get-Volume is the simplest command for retrieving disk storage information. With this command, you can swiftly check the space details of all volumes in one go. It presents vital information such as the health status, system type, and free/used space in gigabytes. Furthermore, we will demonstrate how to examine the storage space information for a particular drive.

1) Display All Volumes and Space Allocation

Step 1: Go to the Search bar and type PowerShell.

Step 2: Choose the "Run as Administrator" option.

Open PowerShell

Step 3: Type Get-Volume in the PowerShell window and press Enter.

Use Get-Volume command in PowerShell to check disk volume space

Now, you'll see a list of partitions along with their details.

< strong >2) Display a Specific Drive

To inquire about the specifics of a particular drive, for instance, the C drive, type the following command: `Get-Volume -DriveLetter C`. If you need information for a different drive, simply substitute the drive letter as needed.

Change drive letter to get disk space of other disk partiton with PowerShell

Method 2: Check Disk Space with PowerShell Using the Get-PSDrive Command

It's another effective yet straightforward method to check disk space using a cmdlet. Here are two different commands to execute:

# 1. Check the Space of All Drives Translate this into English: # 1. Check the Space on All Drives

This command displays the free disk space of all drives in GB.

Step 1: Open the PowerShell window.

Step 2: Type the Get-PSDrive command and press Enter to execute it.

Get intire disk space

It will display a detailed view of used/free disk space, provider, and root of all partitions on the local drive.

# 2. Check the Space of a Specific Drive To check the space on a specific drive, follow these steps:

To check the used and free disk space for a specific drive, run the following command: `Get-PSDrive C`. Replace 'C' with the letter of the target drive you wish to inspect.

Check specific volume space via powershell

Method 3: Get Disk Space via the Get-WmiObject Command in PowerShell

This method is a slightly more complex but practical alternative to the previously mentioned ones. It offers detailed information about your drives. Two scripts in this method provide comprehensive details, including the media type, the total size of the drive in GB, and the utilized or free space.

< strong >1) Check Total Allocated Space< /strong >

Please copy and paste the following command into PowerShell, then hit Enter.

    Translate the following text into English, focusing only on the translation task: ```markdown Get-WmiObject -Class win32_logicaldisk | Format-Table DeviceId, MediaType, @{n="Size";e={[math]::Round($_.Size/1GB,2)}},@{n="FreeSpace";e={[math]::Round($_.FreeSpace/1GB,2)}} ``` This command retrieves information about logical disks using WMI (Windows Management Instrumentation), and then formats the output as a table with columns for DeviceId, MediaType, Size (rounded to 2 decimal places in GB), and FreeSpace (also rounded to 2 decimal places in GB).

Check total allocated space on hard drive via PowerShell

View the displayed details. You can easily determine the space allocation of all partitions on the local drive.

< strong >2) Check the Storage Capacity Assigned to Each Drive

Execute the following command to inspect the detailed space allocation of each drive specifically. It displays the free and total disk space, along with the free percentage for each drive on your computer.

All you need to do is drag and drop the provided command onto PowerShell. Refer to the screenshot to understand the process.

    Translate the following text into English: ```powershell
  • Get-WmiObject -Class Win32_LogicalDisk |
  • Select-Object -Property DeviceID, VolumeName, @{Label='FreeSpace (Gb)'; expression={($_.FreeSpace/1GB).ToString('F2')}},
  • @{Label='Total (Gb)'; expression={($_.Size/1GB).ToString('F2')}},
  • @{label='FreePercent'; expression={[Math]::Round(($_.freespace / $_.size) * 100, 2)}}|ft
  • ``` This is PowerShell code, which when translated to English reads: ```powershell
  • Get WMI object with the class Win32_LogicalDisk |
  • Select properties: DeviceID, VolumeName, create a new property 'FreeSpace (Gb)' with the expression to calculate free space in GB with two decimal places,
  • create a new property 'Total (Gb)' with the expression to calculate total size in GB with two decimal places,
  • create a new property 'FreePercent' with the expression to round off the percentage of free space over total size to two decimal places, then format the table.
  • ``` Please note that this is a script for retrieving information about logical disks, including device ID, volume name, free space in GB, total size in GB, and the percentage of free space.

Get storage capacity assigned to each drive in Powershell

Personal Thoughts:
PowerShell is a practical tool for checking disk space, but it can be quite challenging for novices to navigate. The risk of accidental data loss due to incorrect commands also poses a concern. In summary, PowerShell might not be the ideal choice for those without prior experience, given its complexity and operational difficulties.

Sorry, I need the text to translate. Please provide the content you want me to translate into English.

If you're a beginner without extensive computing experience or familiarity with PowerShell, we recommend using a reliable third-party tool - tools Partition Master. You can learn more about this software in the following section.

Bonus Tip: Check Disk Space with PowerShell Alternative Software

tools Partition Master is a popular alternative software for checking disk space within minutes. As a free disk space analyzer, it is renowned for its extensive features and user-friendly interface. It offers all the necessary options to help users easily check disk space and free it up. For instance, with its Disk Space Analyzer feature, users can view details for individual drives without needing to perform a scan.

With a single click, you can scan all the drives on your local computer. It provides numerous user-friendly features to assist users. For a step-by-step tutorial, please refer to this guide for assistance:

Step 1. Launch AOMEI Partition Assistant and go to Tools. Download Space Analyzer under Frequently Used Tools.

download space analyzer

Step 2. In the Space Analyzer pop-up window, select the target disk to be analyzed and click Analyze in the upper right corner.

click analyze

Step 3. Wait for a while, and you'll see the detailed data. Click on Folder/File to view different data categories, and click on the small folder icon to see more details within the file.

view the detailed data

This tool also helps you check the total disk space on newer operating systems, like Windows 11.

related articles

How to Check Total Disk Space in Windows 11

This article will present three methods to utilize a professional disk space analyzer, Windows Settings, Disk Management, and Command Prompt to check hard drive space.

Check Total Disk Space in Windows 11

Tools Partition Master versus PowerShell: What Sets This Software Apart in Checking Disk Space

Here's a comparison table for you to review, illustrating how Partition Master with its Disk Space Analyzer function outperforms PowerShell:

Sure, please provide the text that needs to be translated.

Tools Partition Master PowerShell
  • Free analysis of disk space
  • User-friendly, supports all Windows OS
  • Efficient and fast for users of all levels
  • Bonus features for disk space management
  • Free of charge
  • Supported on most Windows systems
  • Suitable for advanced Windows users, not beginner-friendly

Moreover, Partition Master is not just a tool for checking disk space; it also enables you to manage your disk space with the following featured functions:

  • Migrate operating system and clean up data.
  • Automate most management tasks.
  • Inspect and manage hard drives, including creation, formatting, and partitioning.

A Brief Review of PowerShell

PowerShell image

PowerShell is an efficient command-line shell and scripting language tool. It is designed to manage Windows administrator tasks through the use of various commands, scripts, and modules. Users on Windows can carry out different tasks, such as checking disk space, installing Windows Updates, and more.

PowerShell operates seamlessly across all Windows operating systems. Its extensive collection of cmdlets offers users numerous options for executing tasks. For example, users can select from various commands to check disk space using PowerShell and further refine the level of detailed output by incorporating different commands. Owing to its versatility, this tool is widely utilized by professionals.

If you find the tips on this page helpful for checking disk space using PowerShell or its alternative tool, please share and assist more friends around you online:

Sorry, I need more text to translate. Please provide the content you want translated.

Conclusion

We hope this tutorial assists you in checking and managing your disk space. You're free to choose any method to accomplish the task. However, we recommend that only advanced Windows users operate the PowerShell utility. Beginners should consider using Partition Master as it is user-friendly and can be easily operated by individuals with any level of expertise.

Furthermore, we recommend adhering to the provided guidelines to manage your disk space more effectively:

    1. Separate and store document files externally from the system
    2. Extend the C drive and ensure sufficient space is available
    3. Clean up and promptly remove unnecessary junk files or large files
    4. Clear cache or temporary files as needed
    5. Utilize OneDrive's cloud storage for infrequently used files
    6. Regularly empty the recycle bin and delete temporary files

Frequently Asked Questions About Checking Disk Space Using PowerShell

Refer to our FAQs section for answers if you have any further doubts about checking disk space using PowerShell.

**1. What PowerShell script can I use to generate a disk space report?**

If you wish to obtain a disk space report via PowerShell, execute the "Get-PSDrive" command. This will display details such as utilized and available disk space, total capacity, and the amount of space used.

**2. How do I check disk space in CMD?** To check disk space in the Command Prompt (CMD) on Windows, follow these steps: 1. Open the Command Prompt as an administrator: - Press `Win + X` and choose "Command Prompt (Admin)" or "Windows PowerShell (Admin)". 2. In the command prompt, type the following command and press Enter: ``` diskpart ``` 3. A new DiskPart utility will open within the CMD window. Type the following command and press Enter: ``` list disk ``` 4. This will display a list of disks connected to your system. Identify the disk number you want to check (usually Disk 0 for the main drive). 5. Type the following command, replacing `X` with the disk number, and press Enter: ``` select disk X ``` 6. Now, type the following command and press Enter to view the disk's partition information, including free space: ``` detail partition ``` Alternatively, you can use the `dir` command with the `/o:s` switch to sort files by size and get an estimate of the free space at the end of the listing. Type: ``` dir /s /o:s ``` This will show you a directory listing, sorted by file size, and the total disk space used and available near the end of the output.

You can use the CMD (Command Prompt) to check the disk space. Here are the steps:

Step 1: Open the Windows Search bar, type Command Prompt, and click Run as administrator.

Step 2: Type 'wmic diskdrive get size' and press Enter.

It will display the total size of your hard drive.

**3. Can I use PowerShell to check disk space on Windows Servers?**

Yes, to check the disk space on Windows Servers, execute the following command in PowerShell: Get-DiskSpaceReport.

The script will gather information about all Windows Servers and save it as a CSV file on the local disk. Open File Explorer and locate the saved file at C:\Temp\DiskSpaceReport.