Find empty child folders in PowerShell, including hidden entries in the check

  • Published: 2026.12.01
  • Updated: 2026.12.01
  • Windows

A folder can look empty in File Explorer while it still contains a hidden file or an empty subfolder. If you are reviewing a directory before moving or archiving it, PowerShell can list the child folders that contain no entries at all.

List empty child folders

Replace .\workspace with the parent folder you want to inspect. This lists its immediate child folders and checks each one for a file or a subfolder. The command works in Windows PowerShell 5.1 and PowerShell 7.

$root = '.\workspace'
$folders = Get-ChildItem -LiteralPath $root -Directory -Force -ErrorAction Stop

$emptyFolders = foreach ($folder in $folders) {
    $firstEntry = Get-ChildItem -LiteralPath $folder.FullName -Force -ErrorAction Stop |
        Select-Object -First 1
    if ($null -eq $firstEntry) {
        $folder
    }
}

$emptyFolders | Select-Object -ExpandProperty FullName

-Force includes hidden entries in the check. A folder with one hidden file therefore stays out of the results. -LiteralPath keeps characters such as square brackets in folder names literal. The check needs only the first entry to decide whether a folder is nonempty.

Interpret the list

  • A child folder containing only another empty folder still has an entry, so the parent stays out of the list.
  • A blank result can mean there are no child folders or that every child folder contains something.
  • If an access or path error appears, resolve it and rerun the check before relying on the list. -Force does not grant access.

The listing inspects the current contents and makes no changes. For file filters and recursive listings, see filtering files with Get-ChildItem.

References