Clear-Content Powershell now working
-
Tuesday, August 28, 2012 7:30 AM
Hi,
I am new to Powershell. I am referring to Clear-Content example mentioned in http://www.activexperts.com/network-monitor/windowsmanagement/powershell10/0026/
I have a directory d:\data\lab. Inside Lab different directories and subdirectories. each directory and subdirectory contains *.txt file.
I want to write a powershell command which will empty content of all the txt files which are inside d:\data\lab
I am using bellow command
Clear-Content D:\data\Lab\* -Filter *.txt
I tried so many permutation and combination, but its not removing content of text files which are inside d:\data\lab folder.
Can anybody help?
Thanks,
Hemant Shelar
Regards, Hemant Shelar
- Moved by litdevMicrosoft Community Contributor Tuesday, August 28, 2012 5:32 PM (From:Small Basic)
All Replies
-
Tuesday, August 28, 2012 5:45 PM
Try:
Get-Childitem -Path d:\data\lab -filter *.txt | Clear-Content
Grant Ward, a.k.a. Bigteddy
- Edited by BigteddyMicrosoft Community Contributor Tuesday, August 28, 2012 5:45 PM
- Proposed As Answer by Knuckle-Dragger Wednesday, August 29, 2012 5:04 AM
- Marked As Answer by Hemant.Shelar Wednesday, August 29, 2012 5:12 AM
-
Wednesday, August 29, 2012 4:58 AM
Hi,
Thanks for your pointer. Bellow command worked for me. Bit modification to what you told.
Get-ChildItem -Recurse -Path D:\data\Lab -Filter *.txt | Clear-Content
Regards,
Hemant Shelar
Regards, Hemant Shelar
- Marked As Answer by Hemant.Shelar Wednesday, August 29, 2012 5:12 AM

