0
0
PowerShellscripting~20 mins

Why cmdlets are the building blocks in PowerShell - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Cmdlet Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Why are cmdlets considered the building blocks in PowerShell?
Choose the best explanation for why cmdlets are called the building blocks of PowerShell.
ACmdlets are small, single-function commands that can be combined to perform complex tasks.
BCmdlets are graphical tools used to design PowerShell scripts visually.
CCmdlets are large programs that replace the need for scripting in PowerShell.
DCmdlets are only used for managing files and cannot be combined.
Attempts:
2 left
💡 Hint
Think about how small commands can be combined to do bigger jobs.
💻 Command Output
intermediate
2:00remaining
Output of a simple cmdlet pipeline
What is the output of this PowerShell command? Get-Process | Where-Object {$_.CPU -gt 100} | Select-Object -Property Name, CPU
PowerShell
Get-Process | Where-Object {$_.CPU -gt 100} | Select-Object -Property Name, CPU
ANo output because the command is incomplete.
BAn error saying 'CPU property not found'.
CA list of all processes without filtering.
DA list of process names and their CPU usage where CPU is greater than 100.
Attempts:
2 left
💡 Hint
Look at how the pipeline filters and selects properties.
📝 Syntax
advanced
1:30remaining
Identify the correct syntax for creating a custom cmdlet function
Which option shows the correct syntax to define a simple PowerShell function that acts like a cmdlet?
Adef Get-Greeting(Name): return "Hello, Name!"
Bfunction Get-Greeting { param($Name) "Hello, $Name!" }
Cfunction Get-Greeting($Name) { echo "Hello, $Name!" }
Dfunc Get-Greeting { param Name; Write-Output "Hello, Name!" }
Attempts:
2 left
💡 Hint
PowerShell functions use the 'function' keyword and 'param' block.
🔧 Debug
advanced
1:30remaining
Why does this cmdlet pipeline fail?
This PowerShell command fails with an error. What is the cause? Get-Service | Where-Object {$_.Status = 'Running'}
PowerShell
Get-Service | Where-Object {$_.Status = 'Running'}
AGet-Service does not return objects with a Status property.
BWhere-Object cannot be used in pipelines.
CThe '=' operator is used instead of '-eq' for comparison.
DThe command is missing a closing parenthesis.
Attempts:
2 left
💡 Hint
Check the operator used inside the script block for comparison.
🚀 Application
expert
2:30remaining
How many cmdlets are involved in this script?
Consider this PowerShell script: $files = Get-ChildItem -Path C:\Logs -Filter *.log $recent = $files | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-7) } $recent | Sort-Object LastWriteTime | Select-Object -First 5 | ForEach-Object { Write-Output $_.Name } How many distinct cmdlets are used in this script?
PowerShell
$files = Get-ChildItem -Path C:\Logs -Filter *.log
$recent = $files | Where-Object { $_.LastWriteTime -gt (Get-Date).AddDays(-7) }
$recent | Sort-Object LastWriteTime | Select-Object -First 5 | ForEach-Object { Write-Output $_.Name }
A7
B6
C5
D4
Attempts:
2 left
💡 Hint
Count each unique cmdlet name used in the script.