Tip of the Day: Support for Code Regions

Today’s Tip…

One of the cool things about the Windows PowerShell ISE is that it supports code regions.  This allows you to collapse areas of your code to get them out of your way without changing the functionality of what you are writing.

The regions can be created automatically, like in this DoWhile loop.

clip_image001

When collapsed, it looks like this.

clip_image002

Or you can create your own regions using #region and #endregion.

clip_image003

When collapsed…

clip_image004

And if you are just commenting out information, regions will be setup for that as well.

clip_image005

When collapsed…

clip_image006

While my examples are very small, this makes a huge difference when dealing with large scripts.