PowerShell Module Help Editor v2.0 and The Power of Reflector

NOTE: Wassim and the PowerShell team have released an updated version of this tool: http://blogs.msdn.com/b/powershell/archive/2011/02/24/cmdlet-help-editor-v2-0-with-module-support.aspx There is no real need to complete the exercise below unless you wish to do if for educational purposes.

Reflector recently went from a free product to a commercial one which caused quite an uproar in the community. My perception is that most people only use Reflector in very particular circumstances. I use Reflector all the time. In my opinion Reflector is worth every penny of that $35 dollars.  Hopefully I can win a copy though. ;) Although I work at Quest, I am not on the PowerGUI team and have never had access to their source code. Thus the only way I would have been able to create PowerGUI VSX is with Reflector. This post will be about the Power of Reflector.

The PowerShell Cmdlet Help Editor

Back in 2007, Wassim Fayed released the Cmdlet Help Editor. It is a tool that allows users to create cmdlet help for their snap-ins. It worked great! But when PowerShell v2.0 came out there was no word of any type of  update. Modules are completely unsupported using the tool. Here is how to get the help editor to support modules.

What you’ll need:

Open Reflector and add the Reflexil.Reflector.dll to the loaded add-ins. This will give you the ability to view and modify the IL code that makes up .NET assemblies. Now you’ll need to load up the HelpEditor.exe.

Step 1:

Modify the LoadRegisteredPsSnapins method.

Change the first instruction’s operand to “get-module -listavailable”. Then remove the instructions for loading the Microsoft snapins. You’ll be left with the above instructions.

Step 2:

Modify the MyPipelineInvocation method to retrieve only the name from the returned command so that we don’t get any exceptions when trying to grab properties that don’t exist.

What I’ve done is deleted the instructions 35-93. Thus we are left with only the retrieval of the “Name” property.

Step 3:

Modify the LoadPsSnapin method to import modules rather than load snap-ins.

I’ve removed the attempt to load the Snap-In because this will fail because PsSnapinName will be the name of the module. You’ll need to delete instructions 123-171. I’ve also changed the command from simply Get-Command to an Import-Module and Get-Command pipeline.

Here are the instructions for creating the pipeline.

Once you complete these modifications you’ll have to save the new module by selecting the HelpEditor.exe node in Reflector and clicking Save As. Place the patched executable back in the installation directory and load it up.

You’ll see all the modules installed on your system:

Selecting one of the modules and clicking New Help File will interrogate the module just as the original did with snap-ins:

There you have it. A help editor for modules! I’m not going to post the patched exe here because I want to get approval to do so first.

You can leave a response, or trackback from your own site.

4 Responses to “PowerShell Module Help Editor v2.0 and The Power of Reflector”

  1. Poshoholic says:

    Awesome! Can’t wait until you can share the editor! You should also change the text (PSSnapin to Module) and version (1.0 to 2.0?).

  2. [...] This post was mentioned on Twitter by Marco Shaw and Adam Driscoll, Adam Driscoll. Adam Driscoll said: How to create a #PowerShell Help Editor for Modules using @Reflector http://csharpening.net/blog/?p=348 [...]

  3. Roman Kuzmin says:

    Cmdlet help editor is great but I had to invent my own tool for a few reasons. It is a script module, open source by nature :)


    The module builds PowerShell MAML help files from PowerShell help scripts. Help scripts are almost WYSIWYG, they look very similar to the result help. Still, they are just scripts and this makes a lot of useful features easy. One of them is building help files for several cultures.

    The module builds help for cmdlets, functions, scripts, and providers. Hopefully, it might be useful for somebody else but me.

  4. [...] blogged about the Reflexil add-in before. This one is really cool! It allows for modification of the IL and the ability to [...]

Leave a Reply

nine + = 17