I have a server that continues to close the gap on our D: Storage. So, from time to time I go into the location and manually delete files to free some space "Yuck". I have created a simple Powershell script that allows me to configure which files specifically and the dates (this is important) that need to be removed. Unfortunately during my testing, I soon realized the files are permanently deleted and I would rather have them sent to the Trash bin.
Here is the code:
Get-ChildItem -Recurse C:\Temp\TWLogTest\*.* | Where-Object {$_.CreationTime -gt (get-date "12-03- 2016 01:00AM") -and $_.
CreationTime -lt (get-date "10-10-2019 14:00PM")} | Where-Object {$_.name -match "tomcat"} | Remove-Items
Any help, guidance or ideas with implementing a Delete into this specific script would be greatly appreciated. I have looked at Module-Recycle, but still not sure how to add it here.
Thanks, Matt