PowerShell DevOps Coding Snippets

Menu

Finding the sizes for subfolders in a parent folder

I came up with this to find the sizes of each subfolder (one level) in a parent folder. The primary use case is figuring out which users are using excessive amounts of space in their personal folders on a network share, but it’s not limited to that.
This will end up with data suitable for discussing with people (because most of the GUI tools give me pretty pictures, but aren’t really designed for sharing the results with your line manager or the individual users when you have the conversation about cleaning house).

It will report the size both in bytes (for sorting) and in GB/MB/KB/bytes (for ease of communicating), and will also identify the single largest file in each of the subfolders. Useful for when someone has zipped up their entire user folder on their computer and uploaded it to their personal folder…