Contact Info

Crumbtrail

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

Select-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 »

Select-Object

Description
Select properties of objects.

Usage
Select-Object [[-property] Object[]] [-excludeProperty string[]]
              [-expandProperty string] [-first int] [-last int]
                 [-unique] [-inputObject psobject] [CommonParameters]

Options
-property Object[]
       The property or properties to select.

   -excludeProperty string
       Properties that will not be selected.
 
   -expandProperty string
       Select and expand the specified property. If the specified property is  
       an array, for example, each value of the array should be included.

   -first int
       Select int number of objects from the beginning of an array of input objects.
        
   -last int
       Select int number of objects from the end of an array of input objects.

   -unique 
       Select unique objects only, (identical properties and values)
		
   -inputObject psobject
       An object or objects to input to Select-Object. May be pipelined.

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

Example(s)
Display only the name, ID and Working Set(WS) properties of Get-Process:

PS C:\>get-process | select-object ProcessName,Id,WS

Display only the Name and modules properties of Get-Process, use -ExpandProperty to display the details contained within the modules property:

PS C:\>get-process | select-object ProcessName -expandproperty modules | format-list

Display the 5 processes that are using the most memory (WS=Working Set):

PS C:\>get-process | sort-object -property WS | select-object -Last 5

Display the name and claculate the start day of the processes running:

PS C:\>get-process | select-object ProcessName,@{Name="Start Day"; Expression={$_.StartTime.DayOfWeek}}