Here’s a quick one for removing all empty folders within a specified folder structure. Theoeretically (untested) it could work with other situations that address PSDrives (try Get-PSDrive).
My organisation uses FSRM to age data on our “scratch” network shares. Files are automatically removed after 30 days. This introduced a small problem with leaving empty folders behind, causing some confusion. The result is a network share with no old files, but with lots of empty folders. This script will delete all folders with no children. (Note: in our production environment, I have preceded this with a script that deletes all unnecessary/folder state files such as thumbs.db and .ds_store. These files are hidden on their native OSes and while a directory may appear empty, if it contains these files the script below will not handle it (I realise I could have included an exclusion list of files to ignore when deleting directories, but that’s really beyond the scope of what I wanted this script to do).
There's no commenting functionality here. If you'd like to comment, please either mention me (@email@example.com) on Mastodon or email me. I don't have any logging or analytics running on this website, so if you found something useful or interesting it would mean a lot to hear from you.