PowerShell provides Select-Object
cmdlet to select the objects or object properties from the collection. Through this article we are going to disucss the usage of this cmdlet.
Select-Object
cmdlet
This cmdlet is used to select the objects or object properties. This needs a collection; hence we always use this with another cmdlet. The output of another cmdlet is an input to this cmdlet.
This has multiple parameters. To select the object properties, we use its Property parameter.
It supports First, Last and Index parameters to display the first few values, the last few values, and the value at the given index from the collection.
Below are the few Examples:
To display the first 5 processes from the list of currently running processes:
PS C:\> Get-Process | Select-Object -First 5
Similarly, to display the last 5 processes from the list:
PS C:\> Get-Process | Select-Object -Last 5
And even we can display the entry at the given index by using its Index parameter:
PS C:\> Get-Process | Select-Object -Index 10
We discuss more in my upcoming Articles.
[..] David