Get Directory Size (PowerShell command line)
Posted by Shannon Crawford on 10 March 2016 03:35 PM

Get-ChildItem Cmdlet

In order to get an idea of how large a repository is prior to migration or other large operations, they may be using the Properties panel in Windows Explorer. This process takes a very long time if the directory is large due to Windows Explorer reading every file.

It is significantly faster to use the following PowerShell command to get the directory size.

Run the application from a PowerShell prompt from within the directory in question:

PS> Get-ChildItem $directory -recurse | Measure-Object -property length -sum

Finding Large Files

In this case, we’re going to look at the length (or size) of the files. In this example, I want to show all files larger than 50 KB.

PS> Get-ChildItem | Where-Object {$_.Length -gt 50KB}

Usage Link:

Comments (0)