Adding single and multi-line comments in Powershell

After spending some time in Javascript or C#, I'll often find myself going back to Powershell and forgetting how to comment! At first, I'll attempt this:

// Attempt 1
<!-- Attempt 3 -->
/* Attempt 2 */

Obviously, none of those work!

Single-line comment

It takes a while to remember that a single line comment in Powershell starts with a hash:

# This is a single line comment in Powershell

Multi-line comment

To add a comment across multiple lines, wrap it with <# and #>:

	This is a multi-line comment, that spans
	multiple lines!

Using multi-line comments to document functions

You can use the multi-line comments to document your functions, using the following template:

function Do-Stuff {
	What does the function do?

	Describe the function

	.PARAMETER paramOne
	Describe the parameter 'paramOne'

	.PARAMETER paramTwo
	Describe the parameter 'paramTwo'

	Objects you can pipe into the function

	What does the function output?

	Give an example of the script in use, and what it might output

	Related links
	Additional notes

Write-Host "I am a function that does stuff."

This will appear when we use Get-Help, to find out more information about our function:

Get-Help Do-Stuff