PowerShell Quick Tip: Remove files and folders from the Temp directory

If you have a temp directory that has many items in, selecting all from Explorer and then deleting them takes longer than using a simple PowerShell command:

Here is the command you can run:

Get-ChildItem -Path "C:\Windows\Temp" *.* -Recurse | Remove-Item -Force -Recurse

https://everything-powershell.com/wp-content/uploads/2020/08/image-1.png

If there are files in use, you will get an error as below which is normal but the bulk of the items should be removed:

https://everything-powershell.com/wp-content/uploads/2020/08/image-2.png

That is how simple it is to clear out the temp directory.