Get-ChildItem 'C:\DB_Backup' -Recurse | Where {$_.creationtime -lt (Get-Date).AddDays(-10)} | Remove-Item
This is pretty clever on powershell's part, lets step through what it does.Get-ChildItem 'C:\DB_Backup' -RecurseWhat this does is list all of the items in this folder as objects, and I am recursing through all of the folders in this folder, but that is not necessarily needed for this job.
Where {$_.creationtime -lt (Get-Date).AddDays(-10)}The objects in this folder is then piped to this line. Where is an alias for Where-Object. We are using where because we only want to select files with specific attributes from this directory. These attributes are defined by the $_.creationtime. The creation time is then compared to today's date (Get-Date) using -lt (less than). But we only want the files older than 10 days ago, so we subtract 10 from Get-Date, using the AddDays modifier. So now we are listing all of the files older than 10 days, pretty neat, now to delete them.
Remove-ItemThe cmd way of doing things is using del, which is actually an alias for -Remove-Item, neat. This will remove the 10 day old objects we piped to it in the previous line.
Save it all as a .ps1 file and schedule the job in task scheduler to run daily to keep your C drive to size.