Comment

noun

say it: “KOM-ent” /ˈkɑmɛnt/

A note written in a script for people to read, which PowerShell skips when it runs the script.

What is a comment in a PowerShell script?

A comment is a note for the people who read a script. PowerShell skips everything from a # to the end of the line, and everything between <# and #>, so a comment can say what a script does or why a line is there.

# morning.ps1: my start-of-the-day check.
$drive = Get-PSDrive -Name C   # the drive Windows is on
<#
Next: add the weather.
#>

In a sentence

  • “The first comment in morning.ps1 says what the script is for.”
  • “Sam wrapped his to-do notes in a comment between <# and #> so PowerShell would skip them.”

Level: Novice · More PowerShell terms at this level

Updated

In other subjects