Sort-Object

Sort-Object permet de trier une collection d'objet en fonction de la valeur de ses propriétés

$names = @( "Aaron", "Albert", "Alphonse","Julien", "Mathieu", "Lucile", "Cédric", "Sébastien")
$names | Sort-Object
Output
Aaron
Albert
Alphonse
Cédric
Julien
Lucile
Mathieu
Sébastien

Pour inverser l'ordre:

$names = @( "Aaron", "Albert", "Alphonse","Julien", "Mathieu", "Lucile", "Cédric", "Sébastien")
$names | Sort-Object -Descending
Get-Process | Sort-Object CPU -Descending
Get-Service | Sort-Object Status