Skip to content

Instantly share code, notes, and snippets.

@yordanoweb
Created February 14, 2025 13:30
Show Gist options
  • Save yordanoweb/0b6a179fb23078c79a763d0c30a351b4 to your computer and use it in GitHub Desktop.
Save yordanoweb/0b6a179fb23078c79a763d0c30a351b4 to your computer and use it in GitHub Desktop.
Current dir size in PowerShell

Current directory size in PowerShell

$size = (Get-ChildItem -Path . -Recurse -File | Measure-Object -Property Length -Sum).Sum
Write-Output "Directory size: $([math]::Round($size / 1MB, 2)) MB"

If you want everything in one line:

$size = (Get-ChildItem -Path . -Recurse -File | Measure-Object -Property Length -Sum).Sum; Write-Output "Directory size: $([math]::Round($size / 1MB, 2)) MB"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment