In one of my recent blogs I talked about how to comment code in PowerShell. That was by using a Hash Tag or a Pound Sign. But what if you would like to comment out multiple lines of code? It would be Inconvenient to Add a Hash Tag against each line of code that you want to comment out. That task is cumbersome and time consuming. Fortunately many programming languages and scripting tools have a way of commenting out multiple lines of code.
In Power Shell, one could comment out multiple lines of code by just following these steps-
You can start the comment block by adding this <# to the code. And it can be ended by this #> For Example, this would be the way to comment out a block of code.
$a=5 Write-Host "Initialized a variable" <# $b=2 Write-Host "Initialized a second variable" #>
This example comments out code starting from the place where the variable b was Initialized.