If you need the size of an folder in MB’s. You can use below script to obtain this information. The $FolderSize variable will return the folder size in the following format: 77,84 MB

$Path = "C:\temp"

$FolderItems = (Get-ChildItem $Path -recurse | Measure-Object -property length -sum)      

$FolderSize = "{0:N2}" -f ($FolderItems.sum / 1MB) + " MB"

TIP/NOTE: In my current migration project I ran into some  “too long path errors”:

Get-ChildItem : The specified path, file name, or both are too long. The fully qualified file name must be less than 260 characters, and the directory name must be less than 248 characters.

I used the following script to obtain the folder size of these BIG folders:


It uses RoboCopy which doesn’t use the Windows API and therefore doesn’t have that limitation.