How would I get the file with the maximum date?
BACKUP-20220114.BAK
BACKUP-20220118.BAK
BACKUP-20220120.BAK
How would I select the file with the largest date value? I tried just finding the maximum string, but alas strings are not compared that way in powershell.
ls BACKUP* | select-object -Property Name | Measure-Object -Maximum
Measure-Object : Cannot compare "@{Name=BACKUP-20221028.bak}" because it is not IComparable.
How do I imbue the string with an IComparable?