I have a script that is designed to remove files after nine days and then removes folders that are empty unless it is named _TrendforMac. The problem is that the script removes folders that have folders still under it. If you create a folder tree several levels deep with the lowest level child folder called “_trendformac”, it will remove the parent folder even though it still has “content”.
Thank you for any help!
Delete the empty folders after cleanup of files unless the folder is named _TrendForMac
You can decide for yourself if you’d like to display the empty folders to the console, or add them to a logfile, just what you like. This might help you to understand what’s happening.
So you might try this below and add a pipe in between your where-object statement and the remove-item statement for “Where-Object {!$_.PSIsContainer}) -eq $null”
After your comment about not being able to recreate the issue, i went back and tried the operation on a Windows 8 laptop with no issues. I then went back and tried the operation again from my Windows 2008 R2 server that i had experienced the problem on originally, and it worked correctly there as well! It has been a good while since i tested the functionality of the part that was broken, so it must have been an update that corrected the problem. I apologize for posting when the problem was already corrected.
Thank you for the prompt response!