Forum Discussion
AngeloLobo_79
Jan 05, 2022Copper Contributor
Script to delete files older than 7 days / Script para deletar arquivos com mais de 7 dias
Hey guys. I would like some help from you. I'm trying to create a script in powershell to delete files that are more than 7 days old. These files are inside subfolders (YY, WW and AA) in the root di...
- Jan 06, 2022Get-ChildItem –Path "C:\XX" -File -Recurse | Where-Object { ($_.LastWriteTime -lt (Get-Date).AddDays(-7)) } | Remove-Item
BenRJ
Copper Contributor
Get-ChildItem –Path "C:\XX" -File -Recurse | Where-Object { ($_.LastWriteTime -lt (Get-Date).AddDays(-7)) } | Remove-Item
AngeloLobo_79
Jan 06, 2022Copper Contributor
Worked perfectly BenRJ. I had entered some incorrect attributes. Now it worked. Thank you for your help.