Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PowerShell script to tidy up the application TEMP area on Windows by deleting files older than 7 days
# The intent is that the command is to be scheduled to be run by the Windows Scheduler once a day:
# For Windows Azure, a new Windows Scheduler task is best added by a Startup Script and, like any other machine with the default PowerShell security settings, will need the PowerShell ExecutionPolicy configured:
# Bill Wilder @codingoutloud
# See also
get-childitem $TEMP -recurse | where {$_.lastwritetime -lt (get-date).adddays(-7)} |% {remove-item $_.fullname -force -recurse -verbose}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment