I have nearly 500k of CCTV files in different folder map to X drive and I need to delete all of them with specific timing such as from 12midnight to 6 am only but keeping the remaining regardless of date. how can I do that? I tried using for files but only seems to filter files for the day and timing also incorrect as it basically doesn't show the files within the defined time.
For PowerShell I got this:
Get-ChildItem -Path c:\your\path\here -Recurse |
Where-Object -FilterScript { $_.LastWriteTime -ge (Get-Date).AddHours(-2) }
but unsure how to modify it to get the list of only 12am to 6am files.