PowerTip: Find Files Modified During a Date Range by Using PowerShell

Summary: Use Windows PowerShell to find files that were modified during a specific date range.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find all files modified during a specific date range?

Hey, Scripting Guy! Answer Use the Get-ChildItem cmdlet to collect the files, filter it to the Where-Object cmdlet, specify the date for the LastWriteTime property, and set greater than and less than parameters:

dir | ? {$_.lastwritetime -gt ‘6/1/13’ -AND $_.lastwritetime -lt ‘6/11/13’}

Note   dir is an alias for the Get-ChildItem cmdlet, and the ? character is an alias for the Where-Object cmdlet. Windows PowerShell automatically converts ‘6/1/13’ into a date for this operation.