Saturday, June 28, 2014

PowerShell 009 - Get-Help -ShowWindow

Help... huh... what is it good for?

The help system in PowerShell is one of the features that makes the new shell so accessible. Once you get used to the system you ask PowerShell questions and it gives you answers. You ask it to clarify, and it does. You ask for more details, it gives you more details. You ask for examples, it gives you examples. It is really, really great.

I was working through some best practices by some of the PowerShell MVPs and I was finding some sample scripts and advanced functions on TechNet and realized that often times writing good help is skipped.

I'm optimistic that the amount of help content I consume will burn into my brain the value of taking the time to write good help content.

-ShowWindow

You can write the help content to the screen and read it from the console. You could even send it right out to a printer, but don't! ("I speak for the trees, for the trees have no tongues" - The Lorax) Sending the help content to the console window is great. When working quickly I often will simply look at examples to get me started;

PS> Get-Help Get-CimInstance -Examples

If I want to see all of the content in the console window;

PS> Get-Help Get-CimInstance -Full

Great. Quick, moves the ball forward nicely. But when learning the subtleties of cmdlets there is often an extensive amount of content to go through. PowerShell's ISE provides a way to throw the content into a single window. It also provides some very interesting features to assist. To get the full content in a separate window type;

PS> Get-Help Get-CimInstance -ShowWindow

Your help content is now in a separate windows. Makes research and troubleshooting much easier in my opinion.

My poor eyes! The text is small, my reading glasses are in the other room, my backup reading glasses are in the couch cushions and my backup, backup reading glasses are who knows! But look... in the bottom right hand of the screen there is a slider bar that allows you to magnify the text... nice! Thanks Microsoft! (you can also <CTRL> & + to increase the font size)


Narrow It Down

OK, now there is a lot of content. How do I find what I am looking for. Get-CimInstance (the cmdlet I chose for the example) seems pretty confusing. The first thing I see is syntax. Lots of syntax. There are almost 10 parameter sets to deal with. Seems to be lots of parameters. I'm betting there are lots of examples.

Right at the top left side of the screen you will see a 'Find:' feature. Simply type in the word or phrase you are looking for and let PowerShell (well the ISE) help you.



In the upper right you will find a button called 'Settings'. Click this button and select only the 'type' of content you want displayed in the window.

It is all pretty self-explanatory. Make sure you spend time here. I have surely heard this message from the PowerShell gurus out there and taken it to heart. Another lesson I'm learning the more I develop scripts and tools with PowerShell is the importance of formatting... but that is a discussion for a different day.

No comments:

Post a Comment