Challenge - 5 Problems
Cmdlet Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate1:30remaining
Why are cmdlets considered the building blocks in PowerShell?
Choose the best explanation for why cmdlets are called the building blocks of PowerShell.
Attempts:
2 left
💡 Hint
Think about how small commands can be combined to do bigger jobs.
✗ Incorrect
Cmdlets are simple commands designed to do one job well. By combining them, you can automate complex tasks easily, making them the building blocks of PowerShell.
💻 Command Output
intermediate2: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, CPUAttempts:
2 left
💡 Hint
Look at how the pipeline filters and selects properties.
✗ Incorrect
The command gets all processes, filters those with CPU usage over 100, then shows only their Name and CPU properties.
📝 Syntax
advanced1: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?
Attempts:
2 left
💡 Hint
PowerShell functions use the 'function' keyword and 'param' block.
✗ Incorrect
Option B correctly defines a PowerShell function with a parameter and returns a string using double quotes for variable expansion.
🔧 Debug
advanced1: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'}Attempts:
2 left
💡 Hint
Check the operator used inside the script block for comparison.
✗ Incorrect
In PowerShell, '=' is for assignment, while '-eq' is for comparison. Using '=' causes an error in the filter.
🚀 Application
expert2: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 }Attempts:
2 left
💡 Hint
Count each unique cmdlet name used in the script.
✗ Incorrect
The distinct cmdlets used are Get-ChildItem, Where-Object, Get-Date, Sort-Object, Select-Object, ForEach-Object, and Write-Output. Total: 7.