Comments

To create single-line comments, begin a line with the character #. Windows PowerShell does not support multi-line comments, but it is possible to deactivate larger regions of your script by placing them in a here string:

# This is a regular comment

# Start of the here string
$null = @"
function MyTest
{
       "This should not be considered a function"
}

$myVariable = 10;
"@
# End of the here string

# This is regular script again

Note

See the section “Strings” to learn more about here strings.

Get Windows PowerShell Quick Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.