PowerShell object filtering and selection¶
PowerShell treats output as structured objects rather than plain text, allowing users to filter, sort, and select specific data properties using a pipeline.^[600-developer__learn-powershell01.md]
Core Filtering Objects¶
Select-Object is used to choose specific properties from an object or to select entire objects based on their position in a collection. For example, selecting all properties of a specific process ID is achieved by piping the object into Select-Object *.^[600-developer__learn-powershell01.md]
Format-List is utilized to display output as a list of properties, where each property is on a new line. This is often used to view detailed fields, such as viewing the Threads property of a specific process object.^[600-developer__learn-powershell01.md]
Format-Table displays output in a tabular format, which is useful for comparing multiple objects side-by-side.^[600-developer__learn-powershell01.md]
Data Organization¶
To sort objects based on a specific property, the Sort-Object cmdlet is used. For instance, processes can be sorted by their memory usage (PM) in descending order.^[600-developer__learn-powershell01.md]
When using Format-Table, the -AutoSize parameter adjusts the column widths to fit the data, preventing truncation and improving readability.^[600-developer__learn-powershell01.md]
Related Concepts¶
- [[PowerShell]]
- [[Pipelining]]
Sources¶
600-developer__learn-powershell01.md