Monthly Archive

Categories

PowerShell comments

Putting comments into your code has been a long established practice – this is how you do PowerShell comments

A single line comment is indicated by the # symbol

# This is a comment
Get-Process

 

You can put a comment at the end of a line but not in the middle. Once you’ve added a comment that’s it for the rest of the line

Get-Process    # This is a comment

In ISE and Visual Studio Code comments are shown in green by default

 

You can also create multi-line comments

<#
This is
a multi-line
comment
#>
Get-Process

 

Be careful if you use # symbols in file names or other data in PowerShell – you may end up with PowerShell thinking you’ve declared a comment

Comments are closed.