How to Utilize PowerShell to Calculate Folder Size on Windows

If you’ve ever wondered which folders are taking up the most space on your Windows computer, knowing their sizes can be incredibly helpful. This knowledge allows you to identify the biggest storage hogs, which can be crucial if you’re looking to move a large folder to a USB drive or cloud storage. While the familiar File Explorer can do this job, it might be time-consuming for really large folders, especially if you’re managing multiple computers in a business or organization. That’s where PowerShell comes in handy. In this guide, we’ll show you how to quickly determine folder sizes on Windows using PowerShell, a powerful tool for managing files and folders.

Finding a Folder’s Size Using PowerShell:

  1. Press the Windows key and type “powershell.”
  2. Right-click on “Windows PowerShell” and choose “Run as administrator.” Confirm with a “Yes” to bypass User Account Control.
  3. In the PowerShell window, enter the following command:
    Get-ChildItem FolderPath | Measure-Object -Property Length -sum

    (Replace “FolderPath” with the directory path containing your target folder.)

  4. The result will display the number of items in the folder and its size in bytes. If you want to convert it to KBs or MBs, divide by 1024 or 1024 twice, respectively. For gigabytes, divide by a million.

Finding Subfolder Sizes Using PowerShell:

If you want to determine the total size of files in a folder and its subfolders, add the -Recurse parameter to the command:

((gci -force c:\Users -Recurse -ErrorAction SilentlyContinue | measure Length -s).sum / 1Gb)

(This command calculates the size of the “c:\Users” directory, including subdirectories and hidden files. The -ErrorAction SilentlyContinue parameter helps suppress potential error messages during the process.)

Getting Subfolder Sizes in a Table Format Using PowerShell:

  1. Open PowerShell ISE by searching for it.
  2. Copy and paste the provided script into the PowerShell ISE console, adjusting the “targetfolder” variable to your preferred directory.
  3. Run the script (F5), and you’ll see a graphical “Size Of Subdirectories” dialog listing all subdirectories and their sizes.

Using PowerShell for Advanced Folder Size Calculations:

PowerShell offers powerful comparison operators to filter results based on specific criteria, such as file creation dates. For example, to get file sizes for folders created within a particular date range:

(gci -force E:\Download –Recurse -ErrorAction SilentlyContinue | ? {$_.CreationTime -gt '01/23/23' -AND $_.CreationTime -lt '02/23/23'}| measure Length -s).sum / 1Gb

(Feel free to customize and experiment with these PowerShell commands to suit your specific needs and efficiently manage your folders and files.)


In a nutshell, PowerShell provides a robust method for calculating folder sizes on Windows, offering valuable insights into your storage consumption. Its versatility allows you to assess single folders or delve into subdirectory sizes. You can even filter results based on criteria like creation dates, enhancing your file and folder management. By using these commands, you can efficiently optimize your Windows experience and take control of your storage space. With this guide, you’re equipped to make the most out of PowerShell for effective folder size management.

Leave a Comment