Powershell: Get Folder Size ‘Quickly’

KB ID 0001660


Right clicking a folder and selecting properties is usually how you would see how large a folder is. Which is great, but if your folder size is HUGE (i.e. many terabytes) then this takes ages!


If you use PowerShell you can get the figure considerably quicker! Below I want to ge the size of E:\Shared;

In MegaBytes;
"{0:N2}" -f ((Get-ChildItem -path E:\Shared -recurse | Measure-Object -property length -sum ).sum /1MB) + " MB"

In GigaBytes;
"{0:N2}" -f ((Get-ChildItem -path E:\Shared -recurse | Measure-Object -property length -sum ).sum /1GB) + " GB"

In TeraBytes;
"{0:N2}" -f ((Get-ChildItem -path E:\Shared -recurse | Measure-Object -property length -sum ).sum /1TB) + " TB"

You can even save this as a ‘function’ then call it whenever you wish.

function Get-FolderSize
 "{0:N2}" -f ((gci -path $pth -recurse | measure-object -property length -sum).sum /1GB) + " GB"

Get Folder Size With PowerShell


Related Articles, References, Credits, or External Links


Author: PeteLong

Share This Post On


  1. In the screen shot you provide the parameter name in the function is hard coded to the value E:\Shared and not the variable name defined b ythe parameter.

    Post a Reply
    • Hi Darryn yes the screenshot is incorrect 🙂


      Post a Reply
  2. Hi! How long does the script usually take for folder size in TB, compared to selecting the folder properties? Does it have a significant difference? Thank you!

    Post a Reply
    • Yes – it can take a while if the target is sufficiently large – Apply a cup of coffee per TB at least 🙂

      Post a Reply

Submit a Comment

Your email address will not be published. Required fields are marked *