Limit the number of Get-ChildItem results

You can use the Select-Object:

Get-ChildItem . | Select-Object -last 1

If you want the latest file, something like:

Get-ChildItem . | Sort-Object LastWriteTime | select -last 1

And of course you can get only the properties that you are interested in with Select-Object as well:

Get-ChildItem .  | Sort-Object LastWriteTime | Select-Object -last 1 Name,LastWriteTime

And you can pipe that to Export-Csv.

Aliases can also be used, Get-ChildItemgci, Select-Objectselect, and Sort-Objectsort.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)