PowerShell CommentsWhen you want to help others by providing the information about a code, then you must use the comments in that code. Just like other programming or scripting languages, you can give the comments in a PowerShell for the documentation purpose. In PowerShell, there are two types of comments:
Single line commentSingle line comments are those comments in which you can type a hash symbol # at the beginning of each line. Everything to the right of the hash symbol will be ignored. If you write the multiple lines in a script, you had to use the hash # symbol at the starting of each line. Syntax of Single line commentThe following are the two syntaxes for the single-line comment: Syntax1: Syntax2: ExamplesExample1: This example displays how to use the comment at the end of a line Example2: This example displays how to use the comment before the code and at the end of any statement. Output: 2 4 6 8 10 Multiple line commentWith PowerShell 2.0 or above, multiple line comments or block comments have been introduced. To comment the multiple lines, put the <# symbol at the beginning of the first line and #> symbol at the end of the last line. Syntax of multiple line commentThe following block displays the syntax of multiple line comment: Example: The following example describes how to use the multiple line comment in code. Type the following command to display the output of above example: PS C:\> $fact 120 Next TopicWhat is PowerShell cmdlet |