Block Comments

<Update 01/04/2012: This post was written in 2008, when PowerShell was in version 1. Block comments were introduced in Version 2.>

One of the raging debates that have had within the team is the issue of whether to support block comments.  In PowerShell, we have the comment character #  e.g.

# This is a test
get-Process -Name LSASS # you can put a comment at the end of a line too


There are times when you have a large set of lines that you need to comment out (e.g. code in progress, cutting out code to test something, function headers, etc).  Some believe that we should support a block comment model like C.  e.g.



so you don’t have to put a # in front of every line:

# Now
# is
# the
# time
# to
# use
# PowerShell

Now you can join the debate.  The connect database has a bug filed on this that you can vote on or comment on.

Let us know what you think.

If you need help knowing what to think, let me know and I’ll tell you.  πŸ™‚

Jeffrey Snover [MSFT]
Windows Management Partner Architect
Visit the Windows PowerShell Team blog at:
Visit the Windows PowerShell ScriptCenter at: