jimmylew52
asked on
Powershell script to return files more than two hours old.
I need a Powershell script to return files names in a directory that are more than two hours old. I can retrieve the file names but cannot get it to not report if the files are less than two hours old. Here is what I have:
$Dr_Path is a test file with the directory paths in it.
Get-ChildItem $Dir_Path | Where { $_.CreationTime.Date -lt (Get-Date).AddMinutes(-120 )} | ? {! $_.PsIsContainer}
$Dr_Path is a test file with the directory paths in it.
Get-ChildItem $Dir_Path | Where { $_.CreationTime.Date -lt (Get-Date).AddMinutes(-120
It seems to work for me, what seems to be missing?
ASKER
It reports files that are less than 2 hours old. It reports files that are created in the last 10 minutes.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
That Works!!!
Thank You so much.
Thank You so much.