PowerTip: Use PowerShell to Find Changed Directories

Summary: Use Windows PowerShell to identify directories that changed since a specific date.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find directories that have changed since a specific date?

Hey, Scripting Guy! Answer Use the Get-ChildItem cmdlet and specify only directories. Pipe the results to Where-Object and evaluate the LastWriteTime property (dir is an alias for Get-ChildItem? is an alias for Where-Object).

Windows PowerShell 3.0 syntax:

dir -Directory | ? lastwritetime -gt $([datetime]’4/1/2013′)

Windows PowerShell 2.0 syntax:

dir | ? { $_.psiscontainer -AND $_.Lastwritetime -gt $([datetime]’4/1/2013′)}