How to Comment Out Code in PowerShell Script

PowerShell Code CommentingPowerShell Code Commenting

This guide gives you an overview of code commenting options in PowerShell. Just like any other programming language, you can comment out code in a PowerShell script for documentation purposes.

Single-line comments in PowerShell

To comment out a single line, put '#' in the beginning:

Single line commentSingle line comment

Multiline Comments in PowerShell

To comment out multiple lines, put <# at the beginning and #> at the end of the code.

PowerShell Multiline CommentPowerShell Multiline Comment

 

AddThis Website Tools
Karim Buzdar: About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various websites.
whatsapp
line