HomePowerShellHow to Comment Code in PowerShell ?

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
#>

Share:

Leave a Reply

You May Also Like

Are you looking at importing DscResource with Relative Paths when working in PowerShell? If so, let’s have a look at...
In this post, let’s learn about the Powershell error “The file <Filename> is not digitally signed. You cannot run this...
There are many ways in which you can run your PowerShell Script. In this post , we will how to...