0
0
PowerShellscripting~10 mins

Verb-Noun naming convention in PowerShell - Interactive Code Practice

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

Complete 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'
AGet-Process
BProcessGet
CFetchProcess
DRetrieve-Proc
Attempts:
3 left
💡 Hint
Common Mistakes
Using noun-verb order like 'ProcessGet' instead of 'Get-Process'.
Using verbs not in approved PowerShell verbs list.
2fill in blank
medium

Complete 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'
ASet-UserVariable
BUserSetVariable
CSet-Variable
DVariableSet
Attempts:
3 left
💡 Hint
Common Mistakes
Placing the noun before the verb like 'VariableSet'.
Missing the dash between verb and noun.
3fill in blank
hard

Fix 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'
ADeleteFile
BRemove-File
CFileRemove
DRemoveItem
Attempts:
3 left
💡 Hint
Common Mistakes
Using camel case without dash like 'DeleteFile'.
Placing noun before verb like 'FileRemove'.
4fill in blank
hard

Fill 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'
AGet-ServiceStatus
BSet-Service
CGet-Service
DStart-Service
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.
5fill in blank
hard

Fill 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'
AStop-ProcessByName
BStop-Process
C$ProcessName
DStopped
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.