Monday, January 13, 2014

Learning Powershell - Get all files changed since a certain date

This gets all files from a specified folder, where that file has changed since a certain date and has type .cs (C# source file) or .sql (SQL script file), and outputs the name of the files in ascending order


$projectpath = "D:\Projects\AwesomeProduct"
$date = '12/18/2013'
$files = @(Get-ChildItem $projectpath -r | Where-Object { !$_IsPSContainer -and ($_.LastWriteTime -gt $date) -and ($_.Extension -eq ".cs" -or $_.Extension -eq ".sql") })
$files | select-object "Name" | Sort-Object "Name"

No comments:

Post a Comment

There was an error in this gadget