How do you comment out code in PowerShell (1.0 or 2.0)?
Single line comments start with a hash symbol, everything to the right of the #
will be ignored:
# Comment Here
In PowerShell 2.0 and above multi-line block comments can be used:
<#
Multi
Line
#>
You could use block comments to embed comment text within a command:
Get-Content -Path <# configuration file #> C:\config.ini
Note: Because PowerShell supports Tab Completion you need to be careful about copying and pasting Space + TAB
before comments.
You can make:
(Some basic code) # Use "#" after a line and use:
<#
for more lines
...
...
...
..
.
#>
Use a hashtag followed by a white-space(!) for this:
# comment here
Do not forget the whitespace here! Otherwise it can interfere with internal commands.
E.g. this is NOT a comment:
#requires -runasadmin
You use the hash mark like this
# This is a comment in Powershell
Wikipedia has a good page for keeping track of how to do comments in several popular languages
http://en.wikipedia.org/wiki/Comparison_of_programming_languages_(syntax)#Comments