A lot of users are confused about what PowerShell cmdlets can get folder size. In this post, MiniTool will explain the PowerShell get folder size in detail. It also introduces a better alternative to list file/folder size on Windows 10/11.

PowerShell is a powerful Windows command-line shell and scripting environment tool that can be used to deal with various works, such as shut down/restart a remote computer, installing Windows updates, copy files, delete file, list file size, and more.

However, a lot of novices and even experienced users are not familiar how to use PowerShell to do these works. Here we will discuss the “PowerShell get file size” cmdlets and introduce an alternative tool. Let’s keep reading to know more details.

CMD Ping Test: How to Ping from Command Prompt Windows 10/11
CMD Ping Test: How to Ping from Command Prompt Windows 10/11

What can you do with the CMD ping test? How to ping from Command Prompt Windows 10/11? How to read the ping test results? Now, you can get the answers here.

Read More

Can PowerShell Get Folder Size

Can PowerShell get file size? Of course, yes. There are various PowerShell cmdlets that can help you get folder/file size in a specified directory. Here we summarize the cmdlets to get folder size PowerShell as follows:

  • Get-ChildItem (gci alias): It should be the most common cmdlet to get PowerShell folder size. This cmdlet allows you to get the list of files/folders size in a specified directory. It can get all items in one or more specified directories, but it doesn’t display empty directory.
  • Measure-Object (measure alias): This cmdlet is mainly used to perform calculations on the property values of objects. You can use it to display the minimum, maximum, and sum size of all files/folders in the current directory.
  • Select-Object (select alias): This cmdlet is used to select specified properties of an object or set of objects. It can display the result and convert bytes into megabytes for the folder/file size.

Now, you should have an overall understanding of the cmdlets related to PowerShell get directory size. Let’s see how to get folder/file size using PowerShell on Windows 10/11.

How to Make PowerShell Get Folder Size on Disk Windows 10/11

How to make PowerShell get size of folders/files on Windows 10/11? The answer varies depending on your needs. Here we summarize several most common examples related to the PowerShell get directory size object.

To open the elevated PowerShell window, type powershell in the search box, right-click Windows PowerShell and select Run as administrator and click on Yes to confirm it. Once opened, you can try the following commands to list folder/file size in a directory.

Example 1: PowerShell Get Folder Size in a Specified Directory

If you want to get the file/folder size in a specified directory, you can refer to the following command. For example, to get the size of the C:Windows10Upgrade folder, you can run the Get-ChildItem C:Windows10Upgrade | Measure-Object -Property Length -sum command.

Get-ChildItem folder path | Measure-Object -Property Length -sum

get folder size PowerShell

If you want to show the total file size of this directory in MB or GB, you can run the following command.

(gci C:Windows10Upgrade | measure Length -s).sum / 1Mb

(gci C:Windows10Upgrade | measure Length -s).sum / 1Gb

If you want to round the size to two decimals, you can run the following command:

"{0:N2} GB" -f ((gci C:Windows10Upgrade | measure Length -s).sum / 1Gb)

show folder size in mb or gb PowerShell

Example 2. PowerShell Get File Size of a Certain Type in a directory

If you want to get the total size of all file sizes of the .exe file type, you can run the following command. Here you can replace exe with other file types like iso, xlsx, etc.

(gci c:exe *.exe | measure Length -s).sum / 1Mb

Example 3. PowerShell Get Directory Size, including subfolders and subdirectories

To get the total size of all files in the directory including subfolders and subdirectories, you can use the –Recurse cmdlet. For example, if you want to get the total size of all files in the C:Windows10Upgrade directory, you can run the following command.

"{0:N2} GB" -f ((gci –force C:Windows10Upgrade –Recurse -ErrorAction SilentlyContinue| measure Length -s).sum / 1Gb)

get directory size using PowerShell

Example 4. PowerShell Get Folder Size on Remote Computers

In addition, PowerShell can help you get folder/file size on remote computers via the Invoke-command cmdlet. Here you need to replace the computername with the actual name of the remote computer.

Invoke-Command -ComputerName hq-srv01 -ScriptBlock ${Function:Get-FolderSize} –ArgumentList 'C:PS'

Better Alternative to PowerShell Get Folder Size

According to the above information, we know PowerShell is a professional tool that can list file/folder/subfolder sizes in a directory. However, it is time-consuming and complex if you are not familiar with these cmdlets. Sometimes you may encounter various errors like “can’t find path”, “running scripts is disabled”, etc.

Is there an effective alternative to the PowerShell list folder size? Of course, yes. MiniTool Partition Wizard is such a tool. It Space Analyzer feature can help you analyze file/folder/directory size on different drives quickly.

Besides, you can search for a file via name or type using the software. If your hard drive or C drive is full, this tool also tells you what files are taking up your disk space and helps free up disk space.

MiniTool Partition Wizard FreeClick to Download100%Clean & Safe

analyze disk space using the MiniTool software

  • linkedin
  • reddit