Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # https://pastebin.com/fmBzGg2W
- # Check out this pastebin entry for a more advanced version: https://pastebin.com/mRhrVdGA
- $Host.UI.RawUI.WindowTitle = 'Empty Folder Remover (Simple)'
- $Target = 'C:\Target'
- Get-ChildItem -LiteralPath $Target -Recurse -Force -Directory -ErrorAction Ignore | Where-Object {(Get-ChildItem -LiteralPath $_.FullName -Recurse -Force -File | Select-Object -First 1).Count -eq 0} | ForEach-Object {
- Remove-Item -LiteralPath $_.FullName -Recurse -Force -ErrorAction Ignore
- "Removed '{0}'" -f $_.FullName
- }
Add Comment
Please, Sign In to add comment