0
0
PowerShellscripting~10 mins

Group-Object for categorization in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to group processes by their name.

PowerShell
Get-Process | Group-Object -Property [1]
Drag options to blanks, or click blank then click option'
AName
BCPU
CId
DPath
Attempts:
3 left
💡 Hint
Common Mistakes
Using Id groups by process ID, which is unique for each process.
2fill in blank
medium

Complete the code to count how many processes are in each group.

PowerShell
Get-Process | Group-Object -Property Name | Select-Object Name, [1]
Drag options to blanks, or click blank then click option'
ASize
BLength
CCount
DTotal
Attempts:
3 left
💡 Hint
Common Mistakes
Using Length or Size which do not exist on group objects.
3fill in blank
hard

Fix the error in the code to group services by status.

PowerShell
Get-Service | Group-Object -Property [1]
Drag options to blanks, or click blank then click option'
AStatus
BServiceName
CDisplayName
DName
Attempts:
3 left
💡 Hint
Common Mistakes
Using ServiceName groups by unique names, not status.
4fill in blank
hard

Fill both blanks to group processes by CPU usage and select the group name and count.

PowerShell
Get-Process | Group-Object -Property [1] | Select-Object [2], Count
Drag options to blanks, or click blank then click option'
ACPU
BName
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up the properties for grouping and selecting.
5fill in blank
hard

Fill all three blanks to group services by status, select the group name, count, and the first service's display name.

PowerShell
Get-Service | Group-Object -Property [1] | Select-Object [2], Count, @{Name='FirstService';Expression={$_.Group[[3]].DisplayName}}
Drag options to blanks, or click blank then click option'
AStatus
BName
C0
D1
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong index for the first service or wrong property names.