I have a directory containing numbered directories:

Archive
 |-1
 |-2
 |-3
 |-...

I need to create the next directory numerically. For which I am currently doing

$lastArchive = ls .\Archive | sort Name | select -Last 1
$dirName = '1'
if($lastArchive) {
  $dirName = ([int]$lastArchive.Name)+1
}

This of course fails once we get to 10 which by sorting rules follows after 1 not 9. I need the sort expression to actually be [int]$_.Name - how would I do this?

Edit
Report