Hello experts,<\/p>\n
I have a folder that has several other folders with same name but different dates<\/p>\n
How can get folder with latest dates ?<\/p>\n
Regards<\/p>\n
Example:<\/p>\n
test(main folder)<\/p>\n
1.2.8.0 11/10/2020 2:56 PM<\/p>\n
1.2.9.0 12/10/2020 4:49 AM<\/p>\n
test 1 version<\/p>","upvoteCount":4,"answerCount":3,"datePublished":"2021-02-25T22:47:13.000Z","author":{"@type":"Person","name":"tkr99","url":"https://community.spiceworks.com/u/tkr99"},"acceptedAnswer":{"@type":"Answer","text":"
Maybe something like this?<\/p>\n
gci \"c:\\path\\to\\folder\" | sort -Property LastWriteTime -Descending | select -First 1\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2021-02-25T22:53:59.000Z","url":"https://community.spiceworks.com/t/get-latest-folder/792021/3","author":{"@type":"Person","name":"titusovermyer","url":"https://community.spiceworks.com/u/titusovermyer"}},"suggestedAnswer":[{"@type":"Answer","text":"Hello experts,<\/p>\n
I have a folder that has several other folders with same name but different dates<\/p>\n
How can get folder with latest dates ?<\/p>\n
Regards<\/p>\n
Example:<\/p>\n
test(main folder)<\/p>\n
1.2.8.0 11/10/2020 2:56 PM<\/p>\n
1.2.9.0 12/10/2020 4:49 AM<\/p>\n
test 1 version<\/p>","upvoteCount":4,"datePublished":"2021-02-25T22:47:13.000Z","url":"https://community.spiceworks.com/t/get-latest-folder/792021/1","author":{"@type":"Person","name":"tkr99","url":"https://community.spiceworks.com/u/tkr99"}},{"@type":"Answer","text":"
use ‘get-childitem’ possibly with ‘-recurse’ depending on your needs.<\/p>\n
e.g.<\/p>\n
CreationTime : 2/21/2019 9:18:43 AM\nCreationTimeUtc : 2/21/2019 4:18:43 PM\nLastAccessTime : 2/1/2021 8:36:15 AM\nLastAccessTimeUtc : 2/1/2021 3:36:15 PM\nLastWriteTime : 2/21/2019 9:39:48 AM\nLastWriteTimeUtc : 2/21/2019 4:39:48 PM\n<\/code><\/pre>\nget-childitem will return a bunch of properties, you can filter and sort after what you need.<\/p>\n
then you can use ‘sort-object’ and get the latest.<\/p>\n
give it a shot.<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n