+ Reply to Thread
Results 1 to 2 of 2

Thread: Check if folder is empty

  1. #1
    Junior Member
    Join Date
    Apr 2012

    Check if folder is empty

    I want to develop a script that deletes the temp folder contents but i`d like to create a function that
    checks if the directory is empty or not.

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Try this...
    $directoryInfo = Get-ChildItem C:\temp | Measure-Object
    $directoryInfo.count #Returns the count of all of the files in the directory
    If $directoryInfo.count -eq 0, then your directory is empty.

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts