locked
Find Empty Folder script RRS feed

  • Question

  • Hello,

    I'm trying to find all empty users folder on my file server. I found this script but it drills down to all the sub folders:

    Get-ChildItem -path E:\users\ -Recurse | Where-Object -FilterScript {$_.PSIsContainer -eq $True} | Where-Object -FilterScript {($_.GetFiles().Count -eq 0) -and $_.GetDirectories().Count -eq 0} | Select-Object -ExpandProperty FullName
    I just want to see if user1 folder is empty and that all. E:\users\user1, E:\users\user2, etc... 

    Thursday, June 20, 2019 3:34 PM

Answers

  • Get-ChildItem -path e:\users\* -Directory |
        Where-Object{$_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0}

    That is a tricky one:


    \_(ツ)_/



    Thursday, June 20, 2019 4:15 PM

All replies

  • Get-ChildItem -path e:\users\* -Directory |
        Where-Object{$_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0}

    That is a tricky one:


    \_(ツ)_/



    Thursday, June 20, 2019 4:15 PM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,

    Lee


    Just do it.

    Friday, June 21, 2019 9:15 AM
  • Thank you! This works great. 
    Monday, June 24, 2019 7:01 PM