Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a function using the Verb-Noun naming convention to get processes.
PowerShell
function [1] {
Get-Process
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using noun-verb order like 'ProcessGet' instead of 'Get-Process'.
Using verbs not in approved PowerShell verbs list.
✗ Incorrect
The correct function name follows the Verb-Noun pattern: 'Get-Process'.
2fill in blank
mediumComplete the code to define a function that sets a user variable following the Verb-Noun naming convention.
PowerShell
function [1] {
param($Name, $Value)
Set-Variable -Name $Name -Value $Value
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Placing the noun before the verb like 'VariableSet'.
Missing the dash between verb and noun.
✗ Incorrect
The function name uses the approved verb 'Set' followed by the noun 'UserVariable' with a dash: 'Set-UserVariable'.
3fill in blank
hardFix the error in the function name to follow the Verb-Noun naming convention.
PowerShell
function [1] {
Remove-Item -Path $Path
} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using camel case without dash like 'DeleteFile'.
Placing noun before verb like 'FileRemove'.
✗ Incorrect
The correct function name uses the approved verb 'Remove' and noun 'File' separated by a dash: 'Remove-File'.
4fill in blank
hardFill both blanks to define a function that gets service status following the Verb-Noun naming convention.
PowerShell
function [1] { param($ServiceName) [2] -Name $ServiceName }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Set-Service' or 'Start-Service' inside a function meant to get info.
Naming the function without a dash or with wrong verb.
✗ Incorrect
The function name is 'Get-ServiceStatus' and inside it calls the 'Get-Service' cmdlet to retrieve service info.
5fill in blank
hardFill all three blanks to define a function that stops a process by name following the Verb-Noun naming convention.
PowerShell
function [1] { param($ProcessName) [2] -Name $ProcessName -Force Write-Output "Process [3] stopped." }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function names without dash or wrong verb.
Not using the 'Stop-Process' cmdlet inside the function.
Outputting a static word like 'Stopped' instead of the process name.
✗ Incorrect
The function name is 'Stop-ProcessByName', it calls 'Stop-Process' cmdlet, and outputs "Process $ProcessName stopped." to confirm.