Multiline comment in PowerShell

PowershellPowershell 2.0

Powershell Problem Overview


Can we comment multiple lines together in PowerShell?

I tried looking, but I didn't find any answer. It's quite irritating to comment each line manually if the script is too long.

Powershell Solutions


Solution 1 - Powershell

In PowerShell v2 and newer, use the following syntax for the multiline comments:

<# a
   b
   c #>

Solution 2 - Powershell

The multiline comment in PowerShell should work.

If not, try this...

# This is
# a
# multiline comment.

or

<#
This does works for me.
#>

If it doesn't work, try to check if you have the correct version of PowerShell.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionNipunView Question on Stackoverflow
Solution 1 - PowershellForNeVeRView Answer on Stackoverflow
Solution 2 - PowershellÜberUser123View Answer on Stackoverflow