PowerShell Find Files Modified After Date

We can use PowerShell to find files modified after a certain date. This task can be useful to find recently modified files on a system. We can use the Get-ChildItem cmdlet to perform this task. The Get-ChildItem CmdLet provides the Recurse parameter which allows us to search in child directories.

1
Get-ChildItem -Recurse | Where-Object { $_.LastWriteTime -gt "07/07/2016" }

Above we search for any files in the current directory and any child directory that have a modification time greater than “07/07/2016”.

PowerShell also provides the Get-Date cmdlet that can be used to get the current date.

1
Get-Date

The Get-Date Cmdlet returns a .net System.DateTime type. We can use any of the methods on this type to manipulate it. For example to find any files created within the last 30 minutes we can use the following command.

1
Get-ChildItem -Recurse | Where-Object { $_.LastWriteTime -le (Get-Date).AddMinutes(-30)}

Conclusion

In this small tutorial we looked at how PowerShell can be used to find files modified after a particular date.