If you're familiar with the term PowerShell and want to know how to check disk space, you might be feeling a bit confused. This guide aims to clarify things for you by introducing the various options available in PowerShell to check disk space and providing alternatives for conveniently showing disk usage.
PowerShell is a powerful built-in tool in Windows that offers convenience in handling various tasks, such as installing Windows updates, working with SSH, getting folder sizes, unzipping/zip files, and running executable files. It provides a seamless command-line shell and scripting environment for efficiently managing tasks.
PowerShell is a cross-PowerShell is a platform task automation solution that offers various functionalities, including easy automation, consistent API, comprehensive type system, built-in data formats, cross-product composability, and more. As a tool designed with different factors, such as a command line shell, configuration management framework, and scripting language, PowerShell can be used to automate tasks and manage systems. To get disk space using PowerShell, you can use the Get-PSDrive cmdlet, which retrieves information about the PowerShell drives, or the Get-Volume cmdlet, which retrieves information about the volumes on the system. For example, you can use the Get-PSDrive cmdlet with the "PS" drive to get the disk space used by the PowerShell drive, or use the Get-Volume cmdlet to get the disk space used by a specific volume.
PowerShell gets disk space and can be used in different types. If you are eager to know these, here we are with the four guides on the other commands for you.
The option provides a list of all volumes available on the system, giving the most straightforward method for PowerShell to get free disk space, where all you can do is display the available disk space.
Show all the drives and space allocation on the computer:
Step 1: To run the Run command on your device, tap the Win + R button together. This will open the Run dialog box, where you can type a command or path to run a specific program or open a folder.
Step 2: Type PowerShell in the given space and hit Enter.
Step 3: Type the command Get-Volume and press Enter.
Step 4: To find the list of drives and their information on a local computer, one can use the command "wmic" in the Command Prompt. This command will list all available drives, their type, size, and other relevant details.
To find the available disk space in GB for all drives, you can use the Get-PSDrive cmdlet in PowerShell. Running this command will display information about each drive, including its provider, root, and used and free disk space. If you want to check the free or used disk space of a specific drive, you can run the Get-PSDrive command followed by the drive letter, such as Get-PSDrive C.
Now, let's learn how to use these commands in PowerShell.
Show the free disk space for all drives on the target computer:
Step 1: Run the Get-PSDrive cmdlet in PowerShell.
Step 2: Once done, you can view the used disks, free disk space, provider, and root for all drives in one paragraph shortly.
The Get-WmiObject cmdlet and the win32_logicaldisk PowerShell script help display the total size, allocated, and free space of logical drives.
Show free space for all drives on your computer:
Step 1: Type 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)}}
Step 2: Once you're done, hit the Enter button, and it will show you the free space for all drives in GB.
Step 3: To acquire the total disk space and free percentage on each drive, you can run the following commands: `df -h` and `df -h --output=size,used,avail,pcent` in your terminal. The first command will display the total disk space and free percentage on each drive, while the second command will display the same information with an additional column showing the percentage of used disk space.
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
You can use the command `df -h` to check the free space on a remote computer. This command will display the disk usage for all mounted file systems, including the remote computer. The `-h` option stands for "human-readable" and will show the free space in a more readable format, such as GB or MB.
To enable total free disk space on remote computers, replace the computer name in the command `Get-WmiObject -Class Win32_logicalDisk -ComputerName srv01,srv02,srv03` with the actual names of the remote computers you want to check. This will give you a detailed view of the free disk space on each machine.
This command helps get total and free disk space on the local and remote computers.
Show free disk space of each drive on the local computer:
Step 1: Run the following command in the PowerShell Prompt:
Get-CimInstance -Class win32_logicaldisk | Format-Table DeviceId, MediaType, @{n="Size";e={[math]::Round($_.Size/1GB,2)}},@{n="FreeSpace";e={[math]::Round($_.FreeSpace/1GB,2)}}
Step 2: Once done, run the `lsblk` command to get complete information about the drives. This command will display detailed information about the storage devices connected to your system, including their size, type, and usage.
Get-CimInstance -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
Replace the computer name "YourComputer" and drive letter "C" in the command `net use YourComputer C: /delete` with your preferred computer name and drive letter. For example, if you want to delete the network connection to your computer named "MyPC" and drive letter "D", the command would be `net use MyPC D: /delete`.
Get-CimInstance -ComputerName computername win32_logicaldisk | where caption -eq "C:" | foreach-object {write " $($_.caption) $('{0:N2}' -f ($_.Size/1gb)) GB total, $('{0:N2}' -f ($_.FreeSpace/1gb)) GB free "}
While PowerShell commands can be tricky, it's essential to type them carefully to avoid data loss. For those who are not comfortable with computing, a reliable third-party tool can be a convenient alternative.
If you don't want to use complicated commands, Qiling Disk Master is a good alternative. It allows you to check the free disk space and other basic information of the disk without needing to use tricky commands.
The tool offers an "extend partition" feature, making it easy for users to get additional disk space. It's a comprehensive Windows partition manager that simplifies various tasks, making it a top-notch option for users.
Step 1. Shrink partition to free up space to extend partition.
If the hard drive has enough unallocated space to extend the target partition, jump to Step 2, and continue. If not, free up space by deleting unnecessary files, emptying the recycle bin, or resizing other partitions to make room for the target partition to be extended.
Step 2. Extend the target partition.
To extend a partition, you need to drag the target partition handle into the unallocated space. This will increase the size of the partition by using the available unallocated space.
Step 3. Keep all changes.
Click the "Proceed" to keep all changes.
To remove the low disk space error efficiently, you can use this method. During the process, you'll be able to see how much space you'll get on your disk, making it easier to manage your storage.
Qiling Disk Master is a free partition software that efficiently performs various tasks, such as adjusting disk space, creating a new partition, merging a section, or setting up a hard drive on Windows, making it a straightforward and suitable option for beginners.
Features of Qiling Disk Master:
The Qiling Disk Master simplifies the process of freeing up disk space, allowing users to quickly reclaim space on their drive with minimal effort and no need to navigate complex commands.
In 2023, you can use PowerShell to get disk space in four different ways, but the related commands can be complicated and may cause issues. A simpler option is to use a third-party tool like Qiling Disk Master, which allows you to get disk space with just a few clicks, making it a more user-friendly choice.
Besides checking disk space, users may also want to check the status of their disk or perform other actions using PowerShell. If you're interested in learning more, I can provide additional links on related topics.
Although we have tried to cover most of the information in this article, some queries can create confusion for you. Here we are with some of the most asked questions that will make things more straightforward.
1. How do I check disk space in PowerShell?
To check the disk space in PowerShell, use the Get-Volume command. You can quickly see the available space on your drives by running this command, and you can also specify a specific drive to check by using the -DriveLetter parameter. For example, you can use Get-Volume -DriveLetter C to check the disk space on the C drive.
The command can provide information about file system volumes, including drive letter, file system, capacity, free space, and other details.
You can also use the fsutil and wmic commands to find the same details.
2. How do I see disk space in CMD?
The Command Prompt is less powerful than Terminal or PowerShell, but you can still check the disk space using the "dir" command with the "/S" option. This option displays the total size of all files and subdirectories in the specified directory, giving you an idea of the disk space usage.
3. How do I check disk space on multiple servers using PowerShell?
You can check the disk space on multiple servers using PowerShell by combining the `Get-WmiObject` and `Foreach-Object` cmdlets. To do this, you'll need to write a script that uses both cmdlets and then execute it.