Learn about Windows PowerShell
Summary: Learn how to hide common code in the Windows PowerShell ISE.
How can I hide related code in the Windows PowerShell ISE to make it easier to troubleshoot and to read?
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:
If($d.name -match ',')
$name = (Get-Culture).textinfo.ToTitleCase($d.name).Split(',').trim()
$ln = $name
$fn = $name
Any chance on fixing the bug in the ISE that requires #region to be lowercase? Its been a bug on connect since 2012.
@DJ - I was just going to post exactly the same comment but you beat me to it!
Interesting that, in the descriptive text at the start of this post, the #Region and #EndRegion are typed correctly :-)
It is not a bug. Directives are always lowercased in nearly all systems.
@jrv Glad it works for you, however it doesn't work for me (and others). PowerShell is, in almost every other respect, case insensitive - and in my opinion this should not be an exception.
There are many examples of case sensitivity in PowerShell and in Net. All properties in AD are case sensitive when referenced as string keys.
is one example. 'name' works. 'Name', 'NAME' or 'nAme' will not work.
@jrv Agreed. It would be nice if they could fix that too (or at least document it :-)
Are you aware of any other cases?
Anyways, it seems they've fixed #Requires in V5 (in the September release in any case...)
@jrv DOH, sorry, prematurely exited. #Region is still not working.....