0
0
PowerShellscripting~20 mins

Comment-based help in PowerShell - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Comment-based Help Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of Get-Help for this function?
Given the following PowerShell function with comment-based help, what will Get-Help Get-Greet display under the DESCRIPTION section?
PowerShell
function Get-Greet {
<#
.SYNOPSIS
Returns a greeting message.
.DESCRIPTION
This function returns a friendly greeting message to the user.
.PARAMETER Name
The name of the person to greet.
.EXAMPLE
Get-Greet -Name "Alice"
#>
param(
  [string]$Name
)
"Hello, $Name!"
}
AThis function returns a friendly greeting message to the user.
BReturns a greeting message.
CThe name of the person to greet.
DGet-Greet -Name "Alice" returns: Hello, Alice!
Attempts:
2 left
💡 Hint
Look for the .DESCRIPTION section inside the comment-based help block.
📝 Syntax
intermediate
2:00remaining
Which comment-based help block is correctly formatted?
Which of the following comment-based help blocks will PowerShell recognize correctly for a function?
A
&lt;##
.SYNOPSIS
Shows current date
#&gt;
B
&lt;#
.SYNOPSIS
Shows current date
#&gt;&gt;
C
&lt;#
.SYNOPSIS
Shows current date
#&gt;
D
&lt;##
.SYNOPSIS
Shows current date
#&gt;&gt;
Attempts:
2 left
💡 Hint
Comment-based help blocks start with <# and end with #> exactly.
🔧 Debug
advanced
2:00remaining
Why does Get-Help not show the .PARAMETER section?
This function has comment-based help, but Get-Help does not show any parameter information. What is the likely cause?
PowerShell
function Test-Param {
<#
.SYNOPSIS
Test function
.PARAMETER Name
The name parameter
#>
param(
  [string]$Name
)
"Hello, $Name"
}
AThe comment-based help block is missing the closing #> delimiter.
BThe comment-based help block must use <## ... #> delimiters.
CThe .PARAMETER section is misspelled and should be .PARAMETERS.
DThe comment-based help block must be placed immediately before the param() block.
Attempts:
2 left
💡 Hint
Check the position of the comment-based help block relative to the param block.
🚀 Application
advanced
2:00remaining
How to add examples in comment-based help?
You want to add two examples to your function's comment-based help. Which format correctly adds multiple examples?
A
&lt;#
.EXAMPLE
Get-Data -Id 1
.EXAMPLE
Get-Data -Id 2
#&gt;
B
&lt;#
.EXAMPLE
Get-Data -Id 1
#&gt;
&lt;#
.EXAMPLE
Get-Data -Id 2
#&gt;
C
&lt;#
.EXAMPLES
Get-Data -Id 1
Get-Data -Id 2
#&gt;
D
&lt;#
.EXAMPLE
Get-Data -Id 1
Get-Data -Id 2
#&gt;
Attempts:
2 left
💡 Hint
Each example uses its own .EXAMPLE section inside the same comment block.
🧠 Conceptual
expert
2:00remaining
What happens if comment-based help is missing .SYNOPSIS?
If a PowerShell function's comment-based help block does not include a .SYNOPSIS section, what will Get-Help display for the synopsis?
AGet-Help will show the first line of the function code as the synopsis.
BGet-Help will display 'No synopsis available.'
CGet-Help will show an empty synopsis section.
DGet-Help will throw an error and not display help.
Attempts:
2 left
💡 Hint
Think about how PowerShell handles missing required help sections.