Powershell – Multiline Comments (Block Comments)

It's hard to believe but you can't do multiline comments in Powershell for some reason! Here is a bit of a hack to allow you to right comments over multiple lines using a multiline string declaration:

@'

This is a hack so
you can do a multiline
comment in powershell
'@ > $null

Points to note...

  • The closing '@ has to be in column 0
  • No whitespace allowed after the opening @'
  • Redirect the output (or cast to [void]) unless you want to see it on the console or in a log file.
SOURCE

LINK

LANGUAGE
ENGLISH