PowerShell uses <# to start a block comment and #> to end it. Put the lines you want ignored between those markers. A single # comments out only the rest of that line, so it won't disable a whole paragraph or several commands on its own.
In this guide
Wrap the complete section in the two markers
Open your .ps1 file in a text editor. Place <# before the first line you want to ignore, then place #> after the final line. Save the file after checking that both markers face the right way.
<#
Prepare the monthly report.
Keep this note beside the commands it explains.
#>
Write-Output 'Report ready'
The two note lines are comments. The final command still runs and prints Report ready. Putting the closing marker on its own line makes the end easy to see when you return to the file later.

A block can contain ordinary notes or commands you temporarily want to disable. Use a copy of an important script while editing. Moving a marker to the wrong place can leave a command active that you meant to comment out.
The PowerShell comment reference describes both comment styles. Windows PowerShell 5.1 and PowerShell 7 accept this basic block syntax; it isn't a Windows 11-only feature.
Use a hash for a single line or an end note
For one line, start it with #. Everything after that character on the line is ignored as comment text, as long as the hash isn't inside quoted text. Code on the next line can still run.
# List the current folder's items.
Get-ChildItem
An end-of-line comment follows code on the same line:
Get-Location # Show the current working folder.
The command still runs because it appears before the comment. Adding a hash at the end doesn't disable what came before it. To turn off that entire command, put the hash before Get-Location.
For a short group of commands, prefixing each selected line with # is also valid. I'd use that approach when the selection already contains block-comment markers, because it avoids closing an outer block accidentally.
These examples run in PowerShell. A Command Prompt window uses a different command language, even when both kinds of shell open inside Windows Terminal. Check the selected shell before trying PowerShell syntax.
Don't nest another block comment inside it
A block comment can contain single-line comments, but it can't safely contain a second block comment. PowerShell ends the outer comment at the first #> it encounters.
That makes wrapping a large section without reading it risky. A closing marker already in the selected text can expose the remaining commands. Search that section for <# and #> before adding another pair.
If the section contains an existing block, comment each line with # instead. Afterward, review both ends of the selection, including any blank gaps. Check that every command you meant to disable is commented out.
For example, disabling three commands needs three leading hashes if you choose line comments. Commenting only the first leaves the second and third commands able to run. Indenting those lines won't stop them from running.
Keep comments separate from quoted text and script blocks
A hash inside a quoted string is text, so this example prints the whole phrase:
Write-Output '# Keep this text'
It doesn't start a comment halfway through the quoted value. The same distinction matters with long strings: text stored in a variable is still data, even if you put notes there.
A here-string is PowerShell's way to write a multiline string. Use <# ... #> when you want a comment instead. That makes it clear which parts of the file PowerShell will ignore.
Braces have another purpose too. A section inside { and } is a script block, a container for code. Braces don't comment out its contents. Code in that block can run when the script calls it.
Before changing a long script, check whether you're looking at comment text, a string value or a script block. They can look similar in a pasted example but do very different things when you run the file.
Check the edited file without executing its commands
Microsoft's parser reference explains how to read a PowerShell file and return syntax errors without running it. That's useful after changing comment markers in a file that performs real work.
In PowerShell, use the actual path to your edited file in this example:
$tokens = $null
$parseErrors = $null
[System.Management.Automation.Language.Parser]::ParseFile(
'C:\Scripts\report.ps1',
[ref]$tokens,
[ref]$parseErrors
) | Out-Null
$parseErrors
The first two lines create variables to hold the results. The parser reads the named file; the final line displays any reported errors.
If nothing appears, the parser found no syntax errors. Review the comments yourself to confirm they cover every command you meant to disable.
Review the active code yourself before running the file. If the path is wrong, correct it first. The PowerShell folder and path guide explains quoted paths and working locations when the script is hard to locate.
Add help text when someone will use the script later
Comment-based help uses the same comment styles with special keywords such as .SYNOPSIS, .DESCRIPTION and .EXAMPLE. That lets someone read the script or function's help with Get-Help.
<#
.SYNOPSIS
Shows the current location.
.DESCRIPTION
Prints the working folder without changing it.
#>
Get-Location
An ordinary block comment doesn't need help keywords. Keep a simple note simple. To add script help, place the help block at the script's beginning or after its final command, following the help instructions.
If a saved script stops with a disabled-scripts message, the comment markers aren't the setting to change. Read the execution-policy checks and follow your organization's policy for that file.
For a remaining parser error, keep a copy and ask the script maintainer to check the reported line and nearby markers. Share a small example with private paths and credentials removed instead of posting the entire working script.
The Short Version
Use <# and #> around a multiline comment, or add # to every line you want ignored. Don't nest block comments. Check the saved file's syntax and review what remains active before running it.
Checked December 2, 2026.







