Thursday, June 19, 2014

List files modified between dates in Powershell

I needed to get a list of files modified between 2 dates.  I used the following in Powershell.  Worth noting is regardless of the date format or regional settings, the date format to be used is mm-dd-yy.  The code below will list all files modified between 30 May 2014 and 02 Apri 2014.

get-childitem -recurse | where-object {$_.lastwritetime -gt '05-30-14' -AND $_.lastwritetime -LT '06-02-14' -AND ! $_.PSIsContainer} | select-object fullname

1 comment:

  1. You can also list files with time ranges using the following:
    get-childitem -recurse | where-object {$_.lastwritetime -gt '05-30-14 2:00:00 pm' -AND $_.lastwritetime -LT '06-02-14 2:30:00 pm' -AND ! $_.PSIsContainer} | select-object fullname
    This will list files between 30 May 2014 2pm and 02 April 2014 2:30pm