Home QuickTipps Inline Comments

Inline Comments

Most of you know the two ways of adding comments to powershell code:


Get-Process # remainder of line is treated as comment

block commenting all of the lines inbetween
the opening and closing tags

  Two types of comments are available in PowerShell

Block comments can also be used to mark selected regions of a line as a comment, though.

Have a look at this line:


<# Some Inline Comment #> Get-Process

  Block comments can be used to place comments at the beginning of a code line – or in the middle of a statement

Unlike with "#", using block comments the comment can be limited to only a portion of the line. Anything following the block comment will still be treated as valid code.