Commented code block in PowerShell

Comment out large blocks of code with PowerShell.

John Savill

March 13, 2016

1 Min Read
Commented code block in PowerShell

Q. How can I create an entire commented block of code in PowerShell?

A. Normally a line of PowerShell can be commented out by prefixing # to the line however if you want to comment multiple lines then the easiest way is to enclose the content in <#  #>. For example

write-output "Start of something"<# all of thiscontent will becommented out #>write-output "Now stuff again"

Each week, John Savill answers all of your toughest tech questions about the worlds of Windows Server, Azure, and beyond. Read his past IT advice here, and email your questions to [email protected].

About the Author

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like