Powershell select most recent file containing a specific string

Viewed 3953

I have written a code in powershell that selects the most recent file in a directory.

$first = Get-ChildItem -Path $dir | Sort-Object CreationTime -Descending | Select-Object -First 1
$first.name

However, I need to select the most recent file containing a specific string in the name. How can I adapt my code in order to do this?

4 Answers
Related