Using PowerShell to get the size of folders (Get-FolderSize function) 0 ▲ Feuerfest 2 hours ago · Tech · hide · 0 comments 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… No comments yet. Log in to reply on the Fediverse. Comments will appear here.