When you are required to check a folder if it is really empty or not with Powershell, this tutorial can help you a lot.

Check if a Folder is Empty in PowerShell

Open PowerShell with administrative privileges and execute the following script.

if( (Get-ChildItem C:\temp | Measure-Object).Count -eq 0)
{
 echo "Folder is empty"
} else { echo "Folder is not empty" }
How to Check if a Folder is Empty in PowerShell

2 thoughts on “How to Check if a Folder is Empty in PowerShell

  • Permalink

    $notEmpty = Test-Path -Path C:TinyTake*
    if ($notEmpty){
    Write-Host -f red “Path is not Empty”
    } else {
    Write-Host -f green “Path is empty”
    }

    Reply
    • Permalink

      or you can do shorter version

      if (Test-Path -Path C:temp*){
      Write-Host -f red “Path is not Empty”
      } else {
      Write-Host -f green “Path is empty”
      }

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Ad #native_company# — #native_desc# #native_cta#