powershellscripts.com

Tutorials  PowerShell Cmdlet Help for Sort-Object



NAME
Sort-Object

SYNOPSIS
Sorts objects by property values.

SYNTAX
Sort-Object [[-Property] ] [-CaseSensitive] [-Culture ] [-Descending] [-InputObject ] [
-Unique] []


DESCRIPTION
The Sort-Object cmdlet sorts objects in ascending or descending order based on the values of properties of the obje
ct.

You can specify a single property or multiple properties (for a multi-key sort), and you can select a case-sensitiv
e or case-insensitive sort. You can also direct Sort-Object to display only the objects with a unique value for a p
articular property.


PARAMETERS
-CaseSensitive []
Indicates that the sort should be case sensitive. By default, sorting is not case sensitive.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Culture
Specifies the cultural configuration to use when sorting.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-Descending []
Sorts the objects in descending order. The default is ascending order.

The Descending parameter applies to all properties. To sort by some properties in
ascending order and others in descending order, you must specify their property values by using a hash table. F
or details, see the examples.

Required? false
Position? named
Default value
Accept pipeline input? false
Accept wildcard characters? false

-InputObject
Specifies the objects to be sorted.

When you use the InputObject parameter to submit a collection of items, Sort-Object receives one object that re
presents the collection. Because one object cannot be sorted, Sort-Object returns the entire collection unchang
ed.

To sort objects, pipe them to Sort-Object.

Required? false
Position? named
Default value
Accept pipeline input? true (ByValue)
Accept wildcard characters? false

-Property
Specifies the properties to use when sorting. Objects are sorted based on the values of these properties. Enter
the names of the properties. Wildcards are permitted.

If you specify multiple properties, the objects are first sorted by the first property. If more than one object
has the same value for the first property, those objects are sorted by the second property. This process conti
nues until there are no more specified properties or no groups of objects.

If you do not specify properties, the cmdlet sorts based on default properties for the object type.

The value of the Property parameter can be a new calculated property. To create a calculated, property, use a h
ash table. Valid keys are:

-- Expression or