Let us begin with listing out the processes; we shall look at all the properties the Get-Process cmdlet gives us and look for complex ones.
- Select all the properties that are part of the output of the Get-Process cmdlet. Pick only the first object, so your console is not filled with content.
PS> Get-Process | Select-Object -Property * -First 1
Observe the property, Threads.
- Select the name of the process, the ID and the threads.
PS> Get-Process | Select-Object -Property Name, Id, Threads
- List out all the threads for the pwsh process.
PS> Get-Process pwsh | Select-Object -ExpandProperty Threads
- A lot of content is output. Say, we want just the ID, the priority, and the start time of the resulting output.
PS> Get-Process pwsh | Select-Object -ExpandProperty Threads | Select-Object -Property Id, PriorityLevel, StartTime
This gave us the ID, the priority level and the start time of all the threads that are running under pwsh.
- What if we use ExpandProperty on the ID?
PS> Get-Process pwsh | Select-Object -ExpandProperty Threads | Select-Object -ExpandProperty Id