You are here:

WindowsManagement.com > PowerShell > PowerShell 1.0 > Select-Object
ActiveXperts Network Monitor 2019 proactively manages network servers, devices, databases and more.

Select-Object - PowerShell 1.0

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.

Select-Object


Description
Back up your Hyper-V VMs Easy & Fast. 100% built for Hyper-V. Free for 2 VMs, forever.

Usage


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}}