This little powershell function allows you to get the size of given folder. It has two parameters, -Name which takes file path as argument and -recurse which gets you size of the folders including the recursive items. For this powershell function -name is mandatory parameter and can take values from pipeline by property name.
function Get-FolderSize { [CmdletBinding()] param( [parameter(valuefrompipelinebypropertyname=$true,mandatory=$true)] $Name, [switch] $recurse ) begin {} process { if($recurse) { $colItems = (Get-ChildItem $name -recurse | Measure-Object -property length -sum) "Size of $name is -- " + "{0:N2}" -f ($colItems.sum / 1GB) + " GB" } else { $colItems = (Get-ChildItem $name | Measure-Object -property length -sum) "Size of $name is -- " + "{0:N2}" -f ($colItems.sum / 1GB) + " GB" } } end {} }
Output: