Writing comments are important in your PowerShell script. They help the next maintainers understand your scripts. Or, they will help you understand your own code down the line, say in 6 months from now.
In PowerShell, you can comment in 2 ways:
- Single line comment: Comment starts with pound key(#).
- Multiple lines comment: For multiple line comment, put
<#
at the beginning and#>
at the end.
Here are the examples:
# This is an important variable. $counter = 7 $sum = 88 # The $sum starts from 88. <# This function will do magic stuff. #> Function doMagic() { # Do some magic.... }