Powershell: Wiping out recycle bin and Temp folder

I have recently wrote a script for deleting files from temp folder and consequtively wiping Recycle Bin.

The function below performs the same function, it first deletes the files from temp folder and then wipes out recycle bin.




In the function above $Env:temp is to get the location of temp folder from the environment variables as defined in the system. The Remove-Item -Recurse -Force is the command concatenated to remove the items from the folder recursively. Here, option -Force is to remove all the items without asking for any permissions to delete them.

The $Recycler object is defined to link to the recycle bin. Then in the next line, a loop is run for each item to remove them. The options -Force and -Recurse are used here to avoid any prompt message before delete and recursively delete all the items one by one.

I hope you find it useful! For any queries, comment!

Download the code from github and enjoy.