Contact Info

Crumbtrail

ActiveXperts.com » Administration » Powershell » Powershell 1.0 » Group-Object

Group-Object - Powershell 1.0 CmdLet

ActiveXperts Network Monitor ships with integrated Powershell scripts to monitor complex network. The scripts run out of the box
Download the ActiveXperts Network Monitor FREE version now »

Group-Object

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

Usage
Group-Object [[-property] Object[]] [-caseSensitive]
		  [-noElement] [-culture string]
            [-inputObject psobject] [CommonParameters]

Options
-property Object[]
       The property or list of properties upon which to group.
        
   -caseSensitive
       Group upper and lower case values separately.
        
   -noElement
       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.

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

Example(s)
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