Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to list all services using a cmdlet.
PowerShell
Get-[1] Drag options to blanks, or click blank then click option'
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.
✗ Incorrect
The cmdlet 'Get-Service' lists all services on the system. Cmdlets are simple commands that perform specific tasks.
2fill in blank
mediumComplete 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'
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.
✗ Incorrect
The cmdlet 'Stop-Service' stops a service. Cmdlets are building blocks that let you control system features easily.
3fill in blank
hardFix 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'
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.
✗ Incorrect
Service names are case-insensitive but usually written with the first letter capitalized. 'Spooler' is the correct service name.
4fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-Property' in Where-Object which is incorrect syntax.
Sorting by 'Status' instead of 'Name'.
✗ Incorrect
The 'Where-Object' filters services where Status equals 'Running'. Then 'Sort-Object' sorts them by 'Name'.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variable names not defined in the loop.
Swapping keys and values in the hashtable.
✗ Incorrect
We create a hashtable with keys as service.Name and values as service.Status for each service in the filtered list.