I need a script to delete all files in a folder older than 30 days, leaving any files, and and folders with files in them that are less than 30 days old.
I found the following powershell script that can almost do this, however, the problem with this script as it is currently written is that if the folder is older than 30 days it will delete the folder and all data in it, even if that data is only a day old.
get-childitem d:\temp1 | where {$_.CreationTime -lt (date).adddays(-30)} | remove-item -recurse
http:/
Your help would be much appreciated.