0
0
PowerShellscripting~20 mins

Group-Object for categorization in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PowerShell Group-Object Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Output of Group-Object by Property
What is the output of this PowerShell command grouping processes by their ProcessName property?
PowerShell
Get-Process | Group-Object -Property ProcessName | Select-Object -First 3 | Format-Table Name,Count -AutoSize
A
Name       Count
----       -----
powershell  1
chrome      3
explorer    2
B
Name       Count
----       -----
powershell  2
chrome      3
explorer    1
C
Name       Count
----       -----
powershell  2
chrome      5
explorer    1
D
Name       Count
----       -----
powershell  3
chrome      5
explorer    1
Attempts:
2 left
💡 Hint
Think about how many instances of each process are typically running and how Group-Object counts them.
🧠 Conceptual
intermediate
1:30remaining
Understanding Group-Object Output Structure
Which property of the output objects from Group-Object contains the list of grouped items?
AGroup
BCount
CName
DValue
Attempts:
2 left
💡 Hint
Look for the property that holds the actual items grouped together.
📝 Syntax
advanced
2:00remaining
Correct Syntax for Grouping by Multiple Properties
Which option correctly groups services by both Status and StartType properties?
AGet-Service | Group-Object -Property Status, StartType
BGet-Service | Group-Object -Property Status; StartType
CGet-Service | Group-Object -Property @('Status', 'StartType')
DGet-Service | Group-Object -Property Status StartType
Attempts:
2 left
💡 Hint
Remember how to pass multiple properties as an array in PowerShell.
🔧 Debug
advanced
1:30remaining
Identify the Error in Group-Object Usage
What error will this command produce? Get-Process | Group-Object -Property
PowerShell
Get-Process | Group-Object -Property
AParameterBindingException: Missing argument for parameter 'Property'.
BRuntimeException: Cannot group without a property name.
CNo error, groups by default property.
DSyntaxError: Unexpected end of command.
Attempts:
2 left
💡 Hint
Check if the required parameter is missing its value.
🚀 Application
expert
2:30remaining
Count Unique File Extensions in a Folder
You want to count how many files of each extension exist in a folder using PowerShell. Which command produces the correct output?
AGet-ChildItem -File | Group-Object -Property FullName | Select-Object Name,Count
BGet-ChildItem -File | Group-Object -Property Name | Select-Object Name,Count
CGet-ChildItem -File | Group-Object -Property Length | Select-Object Name,Count
DGet-ChildItem -File | Group-Object -Property Extension | Select-Object Name,Count
Attempts:
2 left
💡 Hint
Think about which property holds the file extension.