Sometime, we accidently delete a big file that is left over in recycle bin. Whether you are using a server or laptop, this might be useful.
You can use PowerShell to periodically clean up the Recycle Bin by deleting its contents. Here's a script that you can schedule to run at specified intervals to perform this cleanup:
# Function to clean up Recycle Bin
Save this script with a .ps1 extension (e.g., Cleanup-RecycleBin.ps1). Then, you can schedule it to run at specified intervals using Task Scheduler in Windows.
Here's how you can schedule it:
1. Open Task Scheduler.
2. Click on "Create Basic Task" or "Create Task" from the right-hand pane.
3. Follow the wizard to specify a name and description for the task.
4. In the "Action" tab, choose "Start a program" and specify the path to PowerShell (C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe).
5. In the "Add arguments" field, specify the path to the script you saved earlier (e.g., C:\Path\To\Script\Cleanup-RecycleBin.ps1).
5. Set the schedule for the task (daily, weekly, etc.).
6. Complete the wizard to create the task.
No comments:
Post a Comment