May 11th, 2013

PowerTip: Use PowerShell to Find Changed Directories

Doctor Scripto
Scripter

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′)}

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.