开发者

How do I write a powershell script that gets the file with the most recent last write time from a folder?

开发者 https://www.devze.com 2022-12-27 00:10 出处:网络
The subject line says it all. I\'d also like to do this using pipes. I figured that I could use Get-ChildItem, Measure-Object and Where-Object, b开发者_如何学Gout Measure-Object doesn\'t like dates.

The subject line says it all. I'd also like to do this using pipes.

I figured that I could use Get-ChildItem, Measure-Object and Where-Object, b开发者_如何学Gout Measure-Object doesn't like dates.

Should I have a script block which loops through each item returned from Get-ChildItem and does a comparison to see if it's the most recent? I thought that there should be a handy PS cmdlet for that.


Get-ChildItem | Sort LastWriteTime -Descending | Select -First 1
0

精彩评论

暂无评论...
验证码 换一张
取 消