June 17th, 2013

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

Doctor Scripto
Scripter

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.

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.