The Multifunctioning DBA

Nov 23 2010   7:05PM GMT

Powershell Find Files modified after a date

Colin Smith Colin Smith Profile: Colin Smith

I recently needed to find all files in a specific directory that had been written to after a specific date. I also wanted to include all subfolders in the search. I decided to use Powershell to do this and man was it simple. First you have to define the date that you are looking for and you have to define the path that you are looking into. Like such:

$date = [datetime] “10-20-2010”

$path = “c:\test”

Then once you have that you can just do a get-childitem and look at the lastwritetime property of the file.

Get-ChildItem -recurse -path $path | select name, lastwritetime | where {$_.lastwritetime -gt $datemodified}

and that is it.

Hope that will help you look for files that have been recently written to or even find files that have not been written to in a very long time.

 Comment on this Post

There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: