0
0
PowerShellscripting~10 mins

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

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

Complete the code to list all services using a cmdlet.

PowerShell
Get-[1]
Drag options to blanks, or click blank then click option'
AProcesses
BService
CItems
DContent
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Get-Process' instead of 'Get-Service' when listing services.
Using 'Get-Content' which reads file content, not services.
2fill in blank
medium

Complete the code to stop a service named 'Spooler' using a cmdlet.

PowerShell
Stop-[1] -Name Spooler
Drag options to blanks, or click blank then click option'
AProcess
BItem
CContent
DService
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Stop-Process' which stops a process, not a service.
Using 'Stop-Item' which deletes files or folders, not services.
3fill in blank
hard

Fix the error in the code to get the status of the 'Spooler' service.

PowerShell
Get-Service -Name [1]
Drag options to blanks, or click blank then click option'
AspoolerService
Bspooler
CSpooler
DSPOOLER
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect service names like 'spoolerService' which does not exist.
Using all lowercase which might still work but is less standard.
4fill in blank
hard

Fill both blanks to create a cmdlet that gets all running services and sorts them by name.

PowerShell
Get-Service | Where-Object [1] -eq 'Running' | Sort-Object [2]
Drag options to blanks, or click blank then click option'
A-Property
BStatus
CName
D-Name
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-Property' in Where-Object which is incorrect syntax.
Sorting by 'Status' instead of 'Name'.
5fill in blank
hard

Fill all three blanks to create a hashtable of service names and their statuses for services starting with 'Win'.

PowerShell
$services = @{}; foreach([3] in (Get-Service | Where-Object Name -like 'Win*')) { $services[[3].[1]] = [3].[2] }
Drag options to blanks, or click blank then click option'
AName
BStatus
C$service
Dsvc
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names not defined in the loop.
Swapping keys and values in the hashtable.