How to Comment Out Code in PowerShell Script

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 comment

Multiline Comments in PowerShell

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

PowerShell Multiline Comment