Same like other programming language, the comments in Powershell will not executed. Comments can be added to explain the function of the code and it can be placed anywhere and anything between them will be treated as a comment. The powershell also supports single line and multi line comments.
Single Line Comments
SYNTAX: #
The comment with the # will handling single line comments. In PowerShell single line comments start with a hash symbol and everything to the right of the # will be ignored.
1 |
$MyFirstVaiable = "Hello" #Example for single line comments. |
Multi-line Comments
Begin the comment with the <# tag, and end the comment with the #> tag for handling multiline. Multi-line comments are typically used to add descriptive help at the start of a script.
SYNTAX: <# #>
1 2 |
$MyFirstVaiable = "Hello" <# Example for Multiple line comments. This variable use to display hello #> |