PowerTip: Use PowerShell to Clean Up Temp Files

The Scripting Guys


Summary: Use Windows PowerShell to delete temporary files.

Hey, Scripting Guy! Question How can I use Windows PowerShell to clean up a bunch of files that are stored in my temp directory?

Hey, Scripting Guy! Answer Use the Get-ChildItem cmdlet (dir is an alias), point it to the $env:temp directory, and pipe the results
           to the Remove-Item cmdlet, for example:

dir $env:TEMP -Recurse | Remove-Item -Force -Recurse

The Scripting Guys
Dr Scripto

Follow Dr   

No Comments.