Using PowerShell to get the size of folders (Get-FolderSize function) 0 ▲ Feuerfest 105 days ago · Tech · hide · Fediverse post On my gaming PC Windows complained that C:\ had only 10GB of free space left. Time to free up some space! In WindowsXP times I used a separate Program called GetFolderSize for this, but nowadays with PowerShell I was like: "Hey, I bet I can do this with PowerShell alone." After a bit of back & forth I came up with the following function: function Get-FolderSize { param([string]$Path = ".") Get-ChildItem $Path -Directory | ForEach-Object { $size = (Get-ChildItem $_.FullName -Recurse -File -ErrorAction SilentlyContinue | Measure-Object -Property Length -Sum).Sum [PSCustomObject]@{ Folder = $_.Name "Size(MB)" = "{0:N2}" -f ($size / 1MB) "Size(GB)" = "{0:N2}" -f ($size / 1GB) } } | Sort-Object { [double]($_."Size(MB)") } -Descending | Format-Table -AutoSize } It worked fine. However I always needed to copy & paste it into the current PowerShell window to have the function available. Hence I had a new question: How do I make this function available for my local Windows? How do I add this… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town