Recursively scans a user-definable temp folder for files at least as old as a specified age, analyzes the folders to determine which ones to recycle, and then sends the folders followed by the files to the recycle bin.
In determining which folders to recycle, the script only marks ones that are empty or whose contents -- including all subfolders and their files -- are at least as old as the specified age. It only marks the highest-level subfolders that meet those criteria, ensuring that the minimum number of folders are sent to the recycle bin.
WinDirStat showing the number of files and subdirs in the %TEMP% folder prior to running Cleanup-TempFolder:

A PowerShell window showing the script running interactively and the user proceeding with default parameters:

WinDirStat showing the number of files and subdirs in the %TEMP% folder after running Cleanup-TempFolder:

Performance is slower than desired due to the recursive nature of the script, and is further slowed when Verbose Output and/or Debug Mode are enabled.