How to Check If a File or Folder Is Empty in PowerShell
To check if a file is empty in PowerShell, get the file with Get-Item and test whether its Length is 0. Length is the file’s size in bytes: Output: Folders need a different test, which I cover further down. I ran every example in PowerShell 7.6 and Windows PowerShell 5.1 against the same sample folder, … Read more