Book Image

PowerShell Troubleshooting Guide

By : Mike Shepard
Book Image

PowerShell Troubleshooting Guide

By: Mike Shepard

Overview of this book

Table of Contents (15 chapters)
PowerShell Troubleshooting Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Comment-based help


As mentioned in Chapter 1, PowerShell Primer, the help system in PowerShell is very useful. When writing functions and scripts in PowerShell, it is important to provide the same kind of documentation so users are able to use the code correctly.

In order to get the minimal amount of help available, the only requirement is to create a function. Take a look at the following screenshot, for example, shows the help content generated automatically for a simple function:

There is even help for specific parameters, as shown in the following screenshot:

It should be clear that PowerShell is using the definition of the function to generate the help content. This is extremely helpful for several reasons, some of which are listed as follows:

  • The syntax section is never out of sync with the definition. There is no need to worry about missing or misspelled parameters or whether the brackets are in the right places.

  • It is not necessary to create a separate file (or any file at all) in order...