Cloud Training (Online)




How to Comment Code in PowerShell ?


If you are new to PowerShell and wondering how to add comments with-in your Powershell code , here’s how you can do it.

How to Comment Code in PowerShell ?

Single Line Comment in PowerShell

# is one of the ways to add a single line comment in PowerShell. It was introduced in PowerShell v1.0.

Eg :

# This is a comment from DeveloperPublish

Multi-line Comment in PowerShell

You can use <# #> to add a multi-line comment in PowerShell. This was introduces in PowerShell 2.0 and is available in 2.0 and higher versions.

Eg :

<# Comment Line 1
    Comment Line 2
    Comment Line 3
#>