Hi All,
I have the below script that will delete files when certain conditions are true and then will also create a log file of what files were deleted.
I need toalso add a section that once the deletion has been done to recheck the files that metthe deletion criteriabut did not delete for whatever reason.( I.e Locked file no admin access etc)
I don't need to know why they didn't delete just a list of what was left behind.
Any ideas?
Text
# Specify The Folder Path - The folder path can be changed as desired. $folderpath = "C:\Users\Users\Power" #Define Folder where logs are located. $LogFolder = "C:\Users\Users\Logs" # This is setting the minimum age of the files, There is no Minus Hours for "Get-Date" so we use Add Hours -3 $max_hours = "-1" # Current Date and Time $curr_date = Get-Date # determine how far back we go based on current date....