Adding help for cmdlets in a MshSnapIn

Now that you know how to create an MshSnapIn, you might want to add help content for all those cmdlets that you developed and get them displayed by “get-help” cmdlet. To add help content you must know how a Monad Cmdlet Help file looks. See any of the *-Help.xml files in Monad installation directory for reference. I wont be describing the format of the help file in this blog (I will do that on some other day. In the mean time please use one of the *-Help.xml files for your reference).

When "add-mshsnapin XYZ.TestNameSpace.MyMshSnapIn" is run on the command-line, Monad engine will look for snapin information under registry key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSH\1\MshSnapIns\{Your_MshSnapIn_Key here}. This key will have information like ApplicationBase, AssemblyName, etc. The monad engine loads the assembly (and if everything succeeds), identifies all the cmdlets/providers that are defined in MshSnapIn assembly. Along with all the necessary information that is required, the engine will add a default help file name which is of format <MshSnapIn assembly name>.dll-Help.xml for every cmdlet/provider that is present in the MshSnapIn assembly.

Later when help engine tries to load help file for a cmdlet, the help engine looks for the help file relative to MshSnapIn “ApplicationBase” directory. Remember this ApplicationBase is added to the registry during MshSnapIn installation phase.

You can control the name of the help file ( infact you can have a separate helpfile for each of your cmdlets/providers ) by creating a Custom MshSnapIn

So here are the steps to add help content to your MshSnapIns:

Create a help file and name it as appropriate

(a) If your snapin is a general MshSnapIn (ie., deriving from System.Management.Automation.MshSnapIn) name it <your dll name>.dll-Help.xml

(b) If your snapin is a custom MshSnapIn (ie., deriving from System.Management.Automation.CustomMshSnapIn) name it according to the information you supplied with “public override Collection<CmdletConfigurationEntry> Cmdlets” property.

When your snapin is deployed make sure the help files are deployed to the same location relative to ApplicationBase.

If you follow the above steps, then “get-help <Your custom MshSnapIn cmdlet>” should display help for your cmdlets.

Hope this helps.

---

Krishna Vutukuri [MSFT]

Monad Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.

Comments

  • Anonymous
    January 29, 2006
    DrTechMech aka Mr.Monad has developed a site dedicated to Monad Scripting.

    He has added a cmdlets list to the site allowing any scripter complete access to print out the many cmdlets found with the Next Generation Monad Scripting enviroment.

    Please give us a warm welcome.

    monadscripting.blogspot.com