I would like to remove specific text files from my folder (D:\Test) using powershell script. Below are the list of files i have in my folder and need to remove files with name "Defrag" in the file name.
I need to remove the files with name "Defrag".
Thanks for your help in advance.
Pratap
PowerShell is really powerful. This one can be done with one line:
Remove-Item -Path "pathtoyourfile\*Defrag*.txt"
And to your second question:
Get-ChildItem -Path "pathtoyourfile\*Defrag*.txt" -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt (Get-Date).AddDays(-15) } | Remove-Item -Force
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With