Menu Close

Tag: powershell

Delete files older than X days

Here’s a quick portion of a PowerShell script I used that will delete files older than X dates from the current date. 123 $path = “path-to-folder”$days= (Get-Date).AddDays(-7)Get-ChildItem -Path $path -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $days} | Remove-Item -Force Simply change…