I am writing a script that will log the changes to the modification date of a specific file. I only care about the single newest file. I want to capture that and save its name and Lastwritetime to a text file.
I am only finding results limiting recursion.
Is there a way to limit the number of results?
You can use the Select-Object:
If you want the latest file, something like:
And of course you can get only the properties that you are interested in with Select-Object as well:
And you can pipe that to Export-Csv.
Aliases can also be used,
Get-ChildItem→gci,Select-Object→select, andSort-Object→sort.