PowerTip: Use PowerShell to Clean Up Temp Files

Doctor Scripto

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


Discussion is closed.

Feedback usabilla icon