PS
Powershell Tutorial Online

Powershell Comments



Comments will not be executed by Powershell.
Comments can be added to explain the Powershell, or to make the code more readable.
Single line comments start with #.
The following example uses single line comments to explain the code:
Like other languages powershell also supports single line and multi line comments.
Initially in PowerShell V1 there's only # to make the text after it a comment. Starting PowerShell V2 Microsoft come up with block comments (multi-line)

Example


<# #>

Copy and Try it

can be used more specifically for SYNOPSIS, DEsCRIPTION, NOTES, LINK help comments.

Script example:

$greeting = "Hello" # This line is single line comment.
# This line is second line comment.
$name = read-host "What is your name?" # This comment line is new.
"$greeting, $name!"

Begin the comment with the <# tag, and end the comment with the #> tag:

<# this is a comment 
   on several
   different
   lines
   #>

Copy and Try it


Powershell Tutorial is optimized for learning technology step by step. Examples might be simplified to improve reading and basic understanding. While using this site, you agree to have read and accepted our terms of use and privacy policy.
Send your suggestions or feedback to [email protected]
Copyright © 2014 by Powershell Tutorial. All Rights Reserved.