Forum Discussion

SimonSays1's avatar
SimonSays1
Copper Contributor
Dec 05, 2021
Solved

Filter by nested properties of type timespan

Hi folks, I am new to powershell and I wanted to understand the concepts behind it and play a bit with filtering by objects resp. by properties. For example I wanted to filter the output of get-proc...
  • AndySvints's avatar
    Dec 06, 2021

    Hello SimonSays1,

    You are correct TotalProcessorTime is TimeSpan and you can use .seconds property to view the seconds.

    The problem that you are facing is related to pipeline processing. In your Where condition you need to use $_ to reference the object that being passed through the pipeline.

    get-process | where {$_.TotalProcessorTime.Seconds -gt 1}

    Reference: about_Pipelines

    Hope that helps.