Created
December 10, 2012 20:27
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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