I’m completely new to powershell and don’t have much experience working on Windows servers so please forgive me if this is a simple problem. The server has the AWS CLI installed and I need to sort the ls command by date and get the most recent file in the bucket. The command
aws s3 ls s3://mybucket/myfolder/ outputs a listing like so with no headers:
2018-01-18 09:04:02 0
2018-01-18 11:00:33 7428 review-logo-btj-100.jpg
2018-01-18 10:58:36 5860 review-logo-dilve-100.jpg
I’ve tried piping the output to
Sort Date -Descending but that has no affect on the output. I’ve managed to successfully isolate the datetime part with a regex and “select-string” but I still don’t seem to be able to sort it properly.
All that said, I was hoping somebody could help me find the best way to get the most recent file from a listing like that.
Thanks in advance!