Powershell script to list last modified files in x days

Let’s say you want to list of files from directory which are modified in last 2 to 3 days with certain extensions. like I would like to list all php files from directory C:\development modified in last 2 days

following PS command gives me exactly that.

PS> C:
PS> cd development
PS> $dtCompare = (Get-Date).AddDays(-3)
PS> get-childitem –recurse | where-object {$_.lastwritetime -gt $dtCompare -and $_.extension -eq “.php”}

Advertisements