0
0
PowerShellscripting~15 mins

Measure-Object for statistics in PowerShell - Mini Project: Build & Apply

Choose your learning style9 modes available
Measure-Object for statistics
📖 Scenario: You work in a small store and want to analyze daily sales numbers to understand your business better.
🎯 Goal: You will create a list of daily sales, set a threshold for high sales, use Measure-Object to get statistics, and finally display the results.
📋 What You'll Learn
Create an array of daily sales numbers
Create a threshold variable for high sales
Use Measure-Object to calculate count, sum, average, minimum, and maximum of sales
Print the statistics clearly
💡 Why This Matters
🌍 Real World
Stores and small businesses often analyze daily sales to understand performance and make decisions.
💼 Career
Knowing how to quickly get statistics from data using Measure-Object is useful for data analysis and reporting tasks in many IT and business roles.
Progress0 / 4 steps
1
Create daily sales data
Create an array called $dailySales with these exact values: 120, 150, 90, 200, 170.
PowerShell
Need a hint?

Use @( ... ) to create an array in PowerShell.

2
Set high sales threshold
Create a variable called $highSalesThreshold and set it to 150.
PowerShell
Need a hint?

Just assign the number 150 to the variable $highSalesThreshold.

3
Calculate sales statistics
Use Measure-Object with -Average, -Sum, -Minimum, -Maximum, and -Count on $dailySales. Store the result in a variable called $stats.
PowerShell
Need a hint?

Use the pipeline | to send $dailySales to Measure-Object with all the needed parameters.

4
Display the statistics
Print the count, sum, average, minimum, and maximum from $stats using Write-Output with clear labels.
PowerShell
Need a hint?

Use Write-Output and access properties like $stats.Count. Round the average to 2 decimals if needed.