Actually it should be:
dir *-*-*-.* | group {$_.name.split("-")[0]]} | foreach {
$_.group | sort lastWriteTime -desc | foreach {$file=0} { if ($file -gt 0) { remove-item $_.fullname -force -whatIf}; $file++}
}
This command groups all file names by their first characters (until the - sign). It sorts each group of files, collection, to have the last version at the top and then removes all files except the last updated file.
The "remove-item $.fullname" should delete the files.
Do you get any output generated by the -whatIf parameter. It should say which file would have been deleted.
---
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com