Windows – Get files older than 7 days then delete them
Get-ChildItem 'C:\path\to\files' | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-7))} | Remove-Item
Get-ChildItem 'C:\path\to\files' | Where-Object {($_.LastWriteTime -lt (Get-Date).AddDays(-7))} | Remove-Item