What is the best way to get the data in $BackupFileList to be sorted with newest folder created first? (NB. It needs to be an array)
I only need the name to show, as that is what I use to populate a list box in an GUI. But I need the list names to be sorted with newest created folder first!??!!
I’ve tried to add the LastWriteTime with | select Name,LastWriteTime and then pipe that Sort-Object -Property LastWriteTime, but it never sorts
I’d really appreciate any help to get this to sort correctly!
Thanks a packet!
Alessandro.
Of course I used another directory to test but it just works as intended. If you don’t need the “LastWriteTime” anymore for your ListBox you can then use
I needed the -Descending to get latest files first, and I added the [ordered] for the hastable too.
Now it populates the array in the correct order, and when I sent it back to Json it shows in correct order for the list box back to the GUI, so thanks again!