Remove temporary files and recycle bin contents from all user profiles on Windows endpoints
This Automox Worklet™ removes accumulated temporary files from all user profiles on your Windows endpoints. The Worklet scans standard temporary directories and purges files that are older than a configurable threshold (default: 30 days).
The Worklet targets the following locations: C:\Windows\Temp, user AppData\Local\Temp, and AppData\Local\Temporary Internet Files. After cleaning these directories, the Worklet empties the Recycle Bin to complete the cleanup process.
Temporary files accumulate continuously on Windows endpoints as programs cache data and operating system processes create working files. Over time, these files consume significant disk space, reducing available storage for critical applications and data.
Removing temporary files improves endpoint performance by freeing disk space and reducing file system overhead. Also, temporary files often contain sensitive information such as cached credentials, browsing history, and temporary document copies. Automated cleanup reduces security risks by removing these potential data exposure points.
In multi-user environments and terminal server scenarios, temporary file accumulation becomes critical. Regularly cleaning these files helps maintain consistent performance for all users on shared systems and reduces system instability caused by corrupted temporary files.
Evaluation phase: The Worklet queries all user profiles on the endpoint using WMI, then scans standard temporary directories for files older than the configured age threshold (default 30 days). It reports whether files are found.
Remediation phase: The Worklet removes all matching files from user temporary directories and system temporary folders. It then empties the Recycle Bin using Get-ChildItem to verify cleanup completes regardless of logged-in user status.
Windows 10 or Windows Server 2016 and later
PowerShell 3.0 or later (included by default on supported Windows versions)
Administrator or local system context required to access user profiles and the Recycle Bin
File age threshold configurable via the $fileAge variable (default: 30 days; set to 0 to remove all files)
After the Worklet completes, your endpoints will have significantly more available disk space. The amount recovered depends on endpoint usage patterns and how long temporary files have accumulated, but typical recovery ranges from hundreds of megabytes to several gigabytes per endpoint.
You will notice improved application launch times, faster file operations, and reduced system sluggishness. The cleanup also reduces the footprint of subsequent system backups since temporary files no longer occupy backup storage. Verify success by checking disk space in File Explorer or using the Get-Volume PowerShell command to confirm free space increased.
Run this Worklet on a pilot Windows endpoint and review evaluation output for clean up temporary files for all users.
Confirm Automox activity logs show successful completion and exit code 0.
Verify endpoint state using checks aligned to evaluation script logic, such as Get-ChildItem, Clear-RecycleBin.
Validate remediation effects from script operations such as Get-ChildItem, Clear-RecycleBin, Get-CimInstance, then rerun evaluation for compliance.
For technical validation, compare endpoint state to the Worklet evaluation logic and remediation flow for clean up temporary files for all users. This supports repeatable maintenance tasks workflows, faster change control review, and auditable compliance evidence.
Useful script references for this Worklet include evaluation operations such as Get-ChildItem, Clear-RecycleBin and remediation operations such as Get-ChildItem, Clear-RecycleBin, Get-CimInstance. Use these indicators to verify that endpoint changes match intended policy outcomes.


By submitting this form you agree to our Master Services Agreement and Privacy Policy.
Already have an account? Log in
Consider Worklets your easy button
A Worklet is an automation script, written in Bash or PowerShell, designed for seamless execution on endpoints – at scale – within the Automox platform. Worklet automation scripts perform configuration, remediation, and the installation or removal of applications and settings across Windows, macOS, and Linux.

AUTOMOX + WORKLETS™
Uncover new possibilities with simple, powerful automation.
By submitting this form you agree to our Master Services Agreement and Privacy Policy