How to write a powershell script file that receives a file with the latest last write time from a folder?

The topic line says it all. I would also like to do this with pipes.

I decided that I could use Get-ChildItem, Measure-Object and Where-Object, but Measure-Object does not like dates.

Should I have a script block that moves through each element returned from Get-ChildItem, and does the comparison perform to find out if this is the last? I thought that for this there should be a convenient PS cmdlet.

+3
source share
1 answer
Get-ChildItem | Sort LastWriteTime -Descending | Select -First 1
+6
source

Source: https://habr.com/ru/post/1741025/


All Articles