- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if the file is empty using PowerShell?
To check if the file is empty using PowerShell, we can use the string method called IsNullorWhiteSpace(). This method provides result true if the file is empty or only contains the white spaces otherwise false.
For example, We have a test2.txt text file which has whitespaces.
But if you have a file like CSV which contains few headers but the data is empty, in that case, Get-Content will show the wrong output because it will consider headers. For example,
Because the file has headers.
PS C:\> Get-Content C:\Temp\NewUsers.csv Name,FirstName,Surname,EMPNumber,Country
In that case, we can use the Import-CSV command inside the brackets.
- How to check if PSCustomObject is empty in PowerShell?
- How to check if the Azure resource group is empty or not using PowerShell?
- How to check if android editText is empty?
- How to check if the computer is connected to a domain using PowerShell?
- How to check if the USB device is connected to the system using PowerShell?
- Python - Check if dictionary is empty
- How to check if a C# list is empty?
- How to check if String is empty in Java?
- How to check if a Laravel collection is empty?
- How to check if the date is adjusted by Daylight saving time using PowerShell?
- How to check if a list is empty in Python?
- How to Check if Android EditText is empty in Kotlin?
- How to check if a string is empty in Kotlin?
- How to check if remote ports are open using PowerShell?