Get Folder Size in PowerShell

param(
        [Parameter(Position=0,Mandatory)]
        [string]$Path
)

Write-Output ""
Write-Output "Info for $Path`:"
Write-Output ""

$Details = Get-ChildItem -Path $Path | Measure-Object -Property Length -Sum
Write-Output "Num Files: $($Details.Count.ToString('#,##0'))"
Write-Output "Num Bytes: $($Details.Sum.ToString('#,##0'))"
Write-Output ""

Save as Get-FolderSize.ps1

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s