Bird
0
0

You have a list of objects with a property Score. How do you calculate the average score using Measure-Object?

hard📝 Application Q15 of 15
PowerShell - Working with Objects
You have a list of objects with a property Score. How do you calculate the average score using Measure-Object?
A<code>Measure-Object $list -Property Score -Average</code>
B<code>$list | Measure-Object -Average Score</code>
C<code>$list | Measure-Object -Property Score -Average</code>
D<code>$list | Measure-Object Score -Average</code>
Step-by-Step Solution
Solution:
  1. Step 1: Use -Property to specify object property

    To measure a property, use -Property Score to tell Measure-Object which field to analyze.
  2. Step 2: Pipe the list and add -Average flag

    Pipe the list into Measure-Object with -Average to get average of the Score property.
  3. Final Answer:

    $list | Measure-Object -Property Score -Average -> Option C
  4. Quick Check:

    Property + Average with pipeline [OK]
Quick Trick: Use -Property with pipeline to measure object fields [OK]
Common Mistakes:
  • Omitting -Property when measuring object fields
  • Passing list as argument instead of piping
  • Placing -Average before property name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes