Have you ever heard of using PowerShell to check disk space but felt confused? If so, this guide will introduce you to the different options for checking disk space using PowerShell and alternative methods for conveniently displaying disk usage.

PowerShell is one of the most powerful command-line shells and scripting environments baked into Windows, providing a seamless convenience for handling various tasks. Be it installing Windows updates, using PowerShell for SSH connections, querying folder sizes, unzipping/compressing files with PowerShell, running exe programs, or checking disk space – PowerShell makes all these things easy.

Please read:

Related Articles

7 Ways to Fix 99% Disk Usage on Windows

Learn effective methods to solve the issue of 99% disk usage on Windows. Optimize system performance with these 7 solutions.

99 Disk Usage

PowerShell Get Disk Space - Step-by-Step Guide

PowerShell is a cross-platform task automation solution that offers a multitude of features, such as effortless automation, a consistent API, a comprehensive type system, built-in data formatting, and the ability to compose across products. Designed with several aspects in mind, including a command-line shell, a configuration management framework, and a scripting language, PowerShell enables a wide range of tasks. Now, let's explore how you can use PowerShell to check disk space: 1. **Open PowerShell:** - On Windows, press `Win + X` and choose 'Windows PowerShell' or 'PowerShell' (depending on your version). - On macOS or Linux, open a terminal and type `pwsh` to launch PowerShell. 2. **Check Disk Space:** Once PowerShell is open, you can use the `Get-PSDrive` cmdlet to view all the drives and their free space. Type the following command and hit Enter: ```powershell Get-PSDrive ``` This will display information about all drives, including the drive letter, provider, root directory, used space, and free space. 3. **View Specific Drive Details:** To get detailed information about a specific drive, for example, the C: drive, use the following command: ```powershell Get-PSDrive -Name C ``` 4. **Display Free Space in Human-Readable Format:** If you want to see the free space in a more human-readable format (like GB or MB), you can use the `Format-Table` cmdlet along with the `-AutoSize` parameter: ```powershell Get-PSDrive C | Format-Table -AutoSize -Property Name, Used, Free, @{Name='Free (GB)'; Expression={($_.Free / 1GB).ToString('N2')}} ``` This command will display the drive name, used space, free space, and the free space in gigabytes (GB), rounded to two decimal places. Remember that the commands may vary slightly depending on your PowerShell version and operating system.

PowerShell can get disk space, and it can do so in a variety of ways. If you're eager to learn more about these, we have four guides on other commands that might interest you.

A PowerShell method to retrieve disk space information using the Get-Volume command with UTF-8 encoding.

This option will display a list of all available volumes on the system. This is the most straightforward way to get disk space information using PowerShell, and you can simply:

Display all drives and their space allocation on the computer:

Step 1: Press the Win + R keys simultaneously to run the "Run" command on your device.

Step 2: Type PowerShell in the search bar, then press Enter.

Step 3: Type the command Get-Volume, and then press Enter.

Get volume command

Step 4: Once done, you will find the list of drives and their information on your local computer.

Note:
Run the command Get-Volume -DriveLetter C in PowerShell. (Replace C with the actual drive letter, and modify for other drives as needed.)

Use the Get-PSDrive command to retrieve disk space information.

You can use the Get-PSDrive cmdlet in PowerShell to check the available disk space (in GB) on all drives. After running the command, you'll see the provider, root directory, and used/remaining disk space for each device. To find out the available or used disk space on a specific drive, simply run the Get-PSDrive + Drive Letter command.

Now, let's see how to use these commands in PowerShell.

Display the available disk space on all drives of the target computer:

Step 1: Run the Get-PSDrive command in PowerShell.

Get PSDrive

Step 2: Once you do that, you'll see the used and available disk space, provider, and root directory for all drives.

Tip:
Run the Get-PSDrive C command to find a specific drive. Replace C with any other drive name.

A PowerShell method to get disk space using the Get-WmiObject command with utf-8 encoding.

The cmdlet and the PowerShell script win32_logicaldisk help display the total size, allocated space, and available space on logical drives.

Display the available space on all drives on the computer:

Step 1: Enter the command:

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)}}

Command to Get a WMI Object

Step 2: Press Enter when done. It will show the available space for all drives in GB.

Step 3: If you want to get the total disk space and the percentage of available space for each disk, run the following command:

The translation of this PowerShell command into English is: 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)}} | Format-Table This command retrieves information about all logical disks on the computer, including Device ID, Volume Name, Free Space in Gb with two decimal places, Total Size in Gb with two decimal places, and the Free Space percentage, and displays it in a table format.

By the way, you can use this command to check the available space on a remote machine:

Tip:

You can easily retrieve the total available disk space on remote computers by replacing the computer name in the above command with the names of the computers you want, for example: Get-WmiObject -Class Win32_LogicalDisk -ComputerName srv01,srv02,srv03.

A PowerShell method to get disk space using the Get-CimInstance command, with the encoding format set to utf-8.

This command is used to get the total and available disk space on both local and remote computers.

Display the available disk space on each drive of the local computer:

Step 1: Run the following command in the PowerShell prompt:

Get-CIMInstance -ClassName Win32_LogicalDisk | Format-Table DeviceId, MediaType, @{n="Size";e={$_.Size/1GB -as [decimal] -round 2}}, @{n="FreeSpace";e={$_.FreeSpace/1GB -as [decimal] -round 2}} This is a PowerShell command that retrieves information about all logical disks on the computer and displays it in a formatted table with the DeviceId, MediaType, disk size in GB rounded to two decimal places, and free space in GB also rounded to two decimal places.

Get CIMInstance command

Step 2: Once done, run the following command to get the complete information about the drive.

Get-WmiObject -Class Win32_LogicalDisk | Select-Object -Property DeviceID, VolumeName, @{Label='Free Space (Gb)'; Expression={$_.FreeSpace / 1GB.ToString('F2')}}, @{Label='Total (Gb)'; Expression={$_.Size / 1GB.ToString('F2')}}, @{Label='Free Percentage'; Expression={[Math]::Round(($_.FreeSpace / $_.Size) * 100, 2)}} | Format-Table

Notice:

Replace the computer name and drive letter in the command with your specific requirements:

Get-CimInstance -ComputerName ComputerName win32_logicaldisk | where caption -eq "C:" | foreach-object {write " $($_.caption) $('{0:N2}' -f ($_.Size/1gb)) GB Total Capacity, $('{0:N2}' -f ($_.FreeSpace/1gb)) GB Available Space "}

This text provides instructions for a Windows PowerShell command that retrieves the total capacity and available space on the C drive of a specified computer (referred to as "ComputerName"). You should replace "ComputerName" with the actual name of the computer you want to query.

Though PowerShell commands can be somewhat intricate and need to be entered precisely to avoid data loss, if you're not comfortable delving into computer operations, you might prefer using a reliable third-party tool to accomplish the task conveniently.

Professional PowerShell Alternative to Check Disk Space – Free & Easy

If you don't want to use complicated commands, you can use a tool like tools Partition Master, which we recommend. It allows you to view all the basic information about your disk, including available space, without any tricky commands.

This tool offers an “extend partition” feature that allows users to acquire disk space more conveniently. It is one of the best all-in-one Windows partition managers out there, making various tasks easier and flawless.

Step 1: Shrink the partition to free up space for the expansion.

If there is enough unallocated space on the hard drive to extend the target partition, skip to Step 2 and proceed. If there isn't enough room, you'll need to free some up first:

    In the "Partition Manager" section, right-click on a partition next to the target one and select "Resize/Move." Drag the ends of the partition to free up space, making sure there's enough unallocated space behind the target partition, then click "OK."
Free up disk space to get unallocated space

Step 2: Extend the target partition.

Right-click the partition you want to expand, and select "Resize/Move."

Extend partition - 1

Drag the target partition handle to the unallocated space to extend the partition.

Sorry, as a text-based model, I'm unable to display or handle images directly. However, based on the English you've provided, it seems to be a text describing an image. If this is an image caption, it might read: "Extended Partition -2", referencing an image with dimensions 478 pixels in height and 800 pixels in width, sourced from "/images/en/screenshot/partition-manager/screenshots/extend-partition-2.png". This typically describes a screenshot in a webpage or document that illustrates how a partition manager software extends a partition.

Step 3: Save all changes.

Click the Run Task button and click Apply to save all changes.

Extend Partition - 3

In this way, you can effectively fix the low disk space error. During the process, you can see clearly how much space you have gained on the disk.

Whether it's adjusting disk space, creating new partitions, merging regions, or setting up a hard drive on Windows, Partition Master handles all tasks with efficiency. It's a simple and easy-to-use free partition software that's perfect for beginners.

Features of MiniTool Partition Wizard:

With the introduction of tools like Partition Master, users are freed from complicated commands and can easily allocate disk space with just a few clicks.

Conclusions

So, folks! Hopefully, you've learned how to check disk space using PowerShell in 2023. There are four different ways you can leverage PowerShell for managing disk space. The commands involved can be intricate and may lead to issues. In this regard, the better option is to opt for a third-party tool, i.e., tools Partition Master. It's a user-friendly tool that allows you to easily check the space on your disk drives with just a few clicks.

Aside from checking disk space, many users are concerned about the status of their disks, or they might want to use PowerShell for other operations. That's why I'm providing some additional links here. Feel free to click on them if you have similar issues.

Frequently Asked Questions About Getting Disk Space with PowerShell

Though we have endeavored to cover most of the information in this article, there may still be some points that leave you puzzled. Here, we have compiled a list of frequently asked questions to help you better understand.

**How to check disk space in PowerShell?** In PowerShell, you can use the `Get-PSDrive` command to view disk space. Here are the basic steps: 1. Open PowerShell (make sure to run it as an administrator). 2. Enter the following command and press Enter: ``` Get-PSDrive -FileSystem ``` 3. This will list all drives along with their associated file system information, including available and total space. If you want more detailed information, you can use the `Get-Volume` command: ```powershell Get-Volume | Format-Table DriveLetter, FileSystemLabel, Size, SizeRemaining, HealthStatus ``` This will display the drive letter, file system label, total size, remaining space, and health status for each drive.

You can use the Get-Volume command in PowerShell to quickly check disk space. You can specify the particular drive to examine using the -DriveLetter parameter.

It also provides information about the file system volumes on the computer, including drive letters, file systems, capacity, available space, and other details.

You can also use the fsutil and wmic commands to find the same information.

**How do I check disk space in CMD?** To view disk space in CMD (Command Prompt), you can use the `df` command. Here's how: 1. Open Command Prompt: Press `Win + R` to open the Run dialog box, type `cmd`, and then hit Enter. 2. In the Command Prompt window, type the following command and press Enter: ``` df -h ``` This will display the capacity and usage of all disks. The `-h` argument makes the output human-readable in formats like KB, MB, GB. If you're using Windows XP or an earlier version, you might need to use the `dir` command to get disk information: 1. In CMD, type the following command and press Enter: ``` dir /s C:\ ``` This will calculate the total size and used space on drive C:. Replace `C:\` with the letter of another drive you want to check. Note that these steps apply to Windows operating systems. For Linux or macOS systems, the `df` command is typically used to view disk space.

Command Prompt isn't as powerful as Terminal or PowerShell, but you can use the "dir" command with the "/S" option to check disk space. The "/S" option shows the total size of all files and subdirectories within the specified directory.

**How to use PowerShell to check disk space on multiple servers?** To use PowerShell to check disk space on multiple servers, follow these steps: 1. First, ensure you have remote access permissions to the servers and that PowerShell Remoting is enabled on the target servers. 2. Create a text file containing the list of servers you want to check, for example, `servers.txt`. Enter each server's name or IP address on a separate line. 3. Use the following PowerShell script, which will iterate through each server in the text file and report its disk space information: ```powershell # Read the list of servers $servers = Get-Content -Path "C:\path\to\servers.txt" foreach ($server in $servers) { # Attempt to connect to the server and retrieve disk information try { $disks = Invoke-Command -ComputerName $server -ScriptBlock { Get-CimInstance -ClassName Win32_LogicalDisk | Select-Object DeviceID, MediaType, @{Name="Size(GB)";Expression={$_.Size/1GB -as [int]}}, @{Name="FreeSpace(GB)";Expression={$_.FreeSpace/1GB -as [int]}} } # Output the results Write-Host "Server: $server" $disks | Format-Table -AutoSize } catch { Write-Warning "Unable to connect to server $server: $_" } } ``` Make sure to replace `C:\path\to\servers.txt` with the actual path to your server list file. The script will display the disk ID, media type, disk size in GB, and available space in GB for each server. 4. Run this script in PowerShell, and it will display the disk space information for all servers. Note: This operation might require administrative privileges to execute.

You can use PowerShell with the Get-WmiObject and Foreach-Object cmdlets to check disk space on multiple servers. You'll need to write a script incorporating these commands and then execute it. Here are the basic steps: 1. First, make sure you're running PowerShell with administrator privileges. 2. Write a script as follows: ```powershell # Define the list of servers $serverList = @("Server1", "Server2", "Server3") # Replace with your server names # Use Foreach-Object to loop through the server list $serverList | ForEach-Object { $server = $_ # Use Get-WmiObject to get disk information from the server $disks = Get-WmiObject -Class Win32_LogicalDisk -ComputerName $server -ErrorAction SilentlyContinue if ($disks) { foreach ($disk in $disks) { Write-Host "Server: $server, Disk: $($disk.DeviceID), Free Space: $($disk.FreeSpace / 1GB) GB" } } else { Write-Host "Unable to connect to server $server" } } ``` 3. Copy and paste the above code into PowerShell, then press Enter to run it. The script will display the available space on each disk for every server in gigabytes (GB). Please note that this script relies on the WMI service running on the target servers. If the WMI service is not running or there are network issues, the connection might fail.