X

Check if a file is empty using PowerShell

To check if a file is empty using PowerShell in Windows, you can use the following command:

if ((Get-Item 'path\to\your\file.txt').length -eq 0) {
  Write-Host "The file is empty."
} else {
  Write-Host "The file is not empty."
}

Replace 'path\to\your\file.txt' with the actual path to your file. This command checks the length of the file. If the length is 0, it means the file is empty; otherwise, it contains some data.

Categories: Windows
Karim Buzdar: About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various websites.
X

Headline

You can control the ways in which we improve and personalize your experience. Please choose whether you wish to allow the following:

Privacy Settings