Get-DirectorySize : Quickly finding what was eating all my hard drive space with PowerShell
One of my machines was inexplicably running out of hard drive space on it’s OS drive. I cleared it down a couple of times, and within a day or two it was full again
I turned to the tool that solves all problems, PowerShell. I wrote a quick and dirty script to take a starting directory, and recurses all directories, measuring the size for each one, You can find the script on my Github here:
It does error on some protected paths, even when run from PowerShell as an administrator, I think you could get around that by running it as a service account, but I didn’t need to in this case.
I checked the whole drive, which took some time, and found the following:
Hmm, that’s a little on the large side:
It seems I hit this bug, which causes the windows.edb which is the windows search cache, to bloat out.
A quick rebuild and so far it seems fine.
I’m sure I could have found a tool to map out the directory size/could have searched for single large files, but it’s nice to have a tool as flexible as PowerShell to quickly nock up a script to help you troubleshoot issues