Skip to content

Instantly share code, notes, and snippets.

Embed
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: http://stackoverflow.com/a/8888886
# 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: http://blogs.msdn.com/b/jimoneil/archive/2011/02/07/azure-startup-tasks-and-powershell-lessons-learned.aspx
# Bill Wilder @codingoutloud
# See also http://blog.codingoutloud.com/2012/12/10/tidy-the-temp-folder-on-windows-azure
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