Skip to content

Instantly share code, notes, and snippets.

@codingoutloud
Created December 10, 2012 20:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codingoutloud/4253147 to your computer and use it in GitHub Desktop.
Save codingoutloud/4253147 to your computer and use it in GitHub Desktop.
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