Have you ever thought of clearing contents of a file from a command line? There is a PowerShell cmdlet you can use to clear contents of a file. Here are the examples:
To clear contents of a file:
- Clear-Content C:\Temp\TestFile.txt
To clear contents of all files with the “.TXT” file extension:
- Clear-Content -path * -filter *.TXT –force
Note: “Clear-Content” just clears the contents of a file. It doesn’t delete the file.
About Nirmal Sharma
Nirmal is a MCSEx3, MCITP and was awarded Microsoft MVP award in Directory Services. He is specialized in Directory Services, Microsoft Clustering, Hyper-V, SQL and Exchange and has been involved in Microsoft Technologies since 1994. In his spare time, he offers technical help by writing tips and articles. Nirmal can be reached at email@example.com.