What is the Verb-Noun naming convention in PowerShell?
It is a way to name commands where the name starts with a verb followed by a noun, like Get-Process. This makes commands easy to understand and consistent.
Click to reveal answer
beginner
Why use the Verb-Noun naming convention in PowerShell scripts?
It helps keep scripts clear and predictable. When you see a command like Set-Item, you know it changes something. This makes scripts easier to read and maintain.
Click to reveal answer
beginner
Give an example of a correct Verb-Noun command name in PowerShell.
An example is Remove-User. Remove is the action (verb), and User is the object (noun).
Click to reveal answer
intermediate
What is a common mistake when naming PowerShell commands?
Using names without a clear verb or noun, like ProcessData or just Data. This makes it hard to know what the command does.
Click to reveal answer
beginner
Name three approved verbs commonly used in PowerShell command names.
Common approved verbs include Get, Set, and Remove. These verbs clearly describe actions.
Click to reveal answer
Which of these is a correct Verb-Noun PowerShell command name?
ARunServiceNow
BStart-Service
CServiceStart
DService_Run
✗ Incorrect
PowerShell commands use a verb followed by a noun, like Start-Service. The others do not follow this pattern.
What does the verb in a Verb-Noun command name represent?
AThe script file name
BThe object to work on
CThe action to perform
DThe output format
✗ Incorrect
The verb shows the action the command will perform, like Get or Set.
Why is it important to use approved verbs in PowerShell command names?
ATo keep commands consistent and clear
BTo make commands run faster
CTo avoid using nouns
DTo make commands shorter
✗ Incorrect
Approved verbs keep command names consistent and easy to understand.
Which of these is NOT an approved verb in PowerShell naming?
AFetch
BGet
CRemove
DSet
✗ Incorrect
Fetch is not an approved verb; Get should be used instead.
What is the noun part in the command New-Item?
ANone
BNew
CNew-Item
DItem
✗ Incorrect
The noun is the object the command works on, here it is Item.
Explain the Verb-Noun naming convention and why it is useful in PowerShell scripting.
Think about how commands like Get-Process or Set-Item are named.
You got /5 concepts.
List three approved verbs you can use in PowerShell command names and give an example command for each.
Approved verbs describe common actions in PowerShell.
You got /4 concepts.
Practice
(1/5)
1. What does the Verb-Noun naming convention in PowerShell primarily help with?
easy
A. Encrypting scripts for security
B. Shortening command names
C. Adding comments to scripts
D. Making commands clear and consistent
Solution
Step 1: Understand the purpose of Verb-Noun naming
The Verb-Noun style is designed to make commands easy to read and understand by showing the action and the target clearly.
Step 2: Identify the main benefit
This naming style helps users quickly know what a command does, improving clarity and consistency.
Final Answer:
Making commands clear and consistent -> Option D
Quick Check:
Verb-Noun naming = clarity and consistency [OK]
Hint: Verb shows action, noun shows target for clarity [OK]
Common Mistakes:
Thinking it shortens command names
Confusing it with script encryption
Believing it adds comments automatically
2. Which of the following is the correct syntax for a PowerShell function name following the Verb-Noun convention?
easy
A. Get-Process
B. ProcessGet
C. GetProcess
D. process-get
Solution
Step 1: Identify the correct Verb-Noun format
The correct format uses a verb, a dash, then a noun, like 'Get-Process'.
Step 2: Compare options
Only Get-Process uses the dash and proper order; others do not follow the convention.
Final Answer:
Get-Process -> Option A
Quick Check:
Verb-Noun = Verb-Noun with dash [OK]
Hint: Look for verb-noun separated by a dash [OK]
Common Mistakes:
Omitting the dash between verb and noun
Reversing noun and verb order
Using camelCase instead of dash
3. What will be the output of this PowerShell command if you define a function named Set-UserName and call it with Set-UserName -Name 'Alice' assuming the function prints the name parameter?
function Set-UserName { param($Name) Write-Output "User name is $Name" }
medium
A. Error: Unknown command
B. Set-UserName -Name Alice
C. User name is Alice
D. User name is $Name
Solution
Step 1: Understand the function definition
The function takes a parameter called Name and outputs a string including that parameter.
Step 2: Analyze the function call
Calling Set-UserName with -Name 'Alice' passes 'Alice' to the $Name parameter, so the output is 'User name is Alice'.
Final Answer:
User name is Alice -> Option C
Quick Check:
Parameter passed correctly = output with name [OK]
Hint: Parameters passed by name show in output [OK]
Common Mistakes:
Expecting the command name as output
Not recognizing variable substitution
Assuming an error without function definition
4. Identify the error in this PowerShell function name that violates the Verb-Noun naming convention:
function Process-Data { Write-Output "Processing" }
medium
A. Verb should be a standard approved verb
B. Noun should come before verb
C. Missing dash between verb and noun
D. Verb is not approved
Solution
Step 1: Check the function name structure
The name 'Process-Data' uses a dash and has verb-noun order, so structure is correct.
Step 2: Verify the verb against approved verbs
'Process' is not an approved PowerShell verb, so it violates the naming convention.
Final Answer:
Verb should be a standard approved verb -> Option A
Quick Check:
Approved verbs required = Verb should be a standard approved verb [OK]
Hint: Use only approved verbs in function names [OK]
Common Mistakes:
Thinking noun comes before verb
Ignoring approved verb list
Assuming dash is missing
5. You want to create a PowerShell function that deletes temporary files. Which of these names follows the Verb-Noun naming convention correctly and uses an approved verb?
hard
A. Erase-TempFiles
B. Remove-TempFiles
C. Delete-TempFiles
D. ClearTempFiles
Solution
Step 1: Identify approved verbs for deleting
PowerShell approved verbs for deleting include 'Remove' and 'Clear', but 'Delete' and 'Erase' are not approved.
Step 2: Check naming format
Remove-TempFiles uses 'Remove' (approved verb), a dash, and 'TempFiles' (noun), following Verb-Noun convention correctly.
Step 3: Evaluate other options
Erase-TempFiles uses unapproved verb 'Erase', Delete-TempFiles uses unapproved verb 'Delete', and ClearTempFiles lacks dash between verb and noun.