Contact Info

Crumbtrail » Administration » Powershell » Powershell 1.0 » Group-Object

Group-Object - Powershell 1.0 CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.


Group the objects that contain the same value for a common property


-property Object[]
       The property or list of properties upon which to group.
       Group upper and lower case values separately.
       Don't include elements of each group in the output objects.

   -culture string
       The culture to use when performing a string comparison.
   -inputObject psobject
       The objects to group. May be pipelined.
       A variable command or expression that gets the objects.

       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.

Display a list of files grouped by size:

PS C:\>get-childitem *.doc | group-object -property length

Display a list of files, sorted and then grouped by the file extension:

PS C:\>get-childitem | sort-object -property extension | group-object -property extension

Count the file extensions (in the current directory) without retrieving all the files:

PS C:\>get-childitem | group-object extension -noelement