How To Find Empty Folders With PowerShell

  1. Open the Microsoft PowerShell ISE → Using an admin account that has full access to your file share, run the following script on the workstation, specifying the network path of the shared drive:
$share = Get-ChildItem '\\pdc\Shared' -Recurse | Where { $_.PsIsContainer -eq $true }

$share | Where { $_.GetFiles().Count -eq 0 -and $_.GetDirectories().Count -eq 0 }
  1. Review the results.
    image

Enjoy!

1 Like