PowerTip: Hide Common Code in PowerShell ISE

Doctor Scripto

Summary: Learn how to hide common code in the Windows PowerShell ISE.

Hey, Scripting Guy! Question How can I hide related code in the Windows PowerShell ISE to make it easier to troubleshoot and to read?

Hey, Scripting Guy! Answer Open the ISE, and in the script pane, begin a section with the #Region tag and a name.
           Then end the section with the #EndRegion tag. Now everything between the two tags can be collapsed
           and hidden when desired. Here is an example:

#region Name

 If($d.name -match  ‘,’)

        {

          $name = (Get-Culture).textinfo.ToTitleCase($d.name).Split(‘,’).trim()

          $ln = $name[0]

          $fn = $name[1]

          }

#endregion

0 comments

Discussion is closed.

Feedback usabilla icon