Creating External help
In the previous post I included a line
# .ExternalHelp Maml-AccessFunctions.XML
in the Add-AccessRecord function.
I have used comment based help in the past but as James found http://blogs.technet.com/jamesone/archive/2009/07/24/powershell-on-line-help-a-change-you-should-make-for-v2-3-and-how-to-author-maml-help-files-for-powershell.aspx it does increase the length of functions and I think makes them harder to understand.
I used the InfoPath template that James supplied and saved the file as accessfunctions.xml. A modification to the first line in the file needs to occur so that it will function as a help file. I can see me creating a number of these files so I decided to script the change.
The script starts by defining what the first line should be. The help files seem to be sensitive to the format of this line so I put it into a here string to get the formatting right. I know what the files are going to be going into this script so I decided to create a switch for each module that sets the path to the xml file produced by InfoPath.
A quick test that the file exists and then we read the content, change the first line and use Set-Content to write it back out. I added a “maml-“ prefix to the file name so that the modified help file is separate to the InfoPath file. This makes editing the help file easier.
The help file is used as normal
get-help add-accessrecord –full etc
InfoPath is one of those products that I’ve never really looked at before. It looks like it should have a number of uses and as it has an object model it should be possible to work with it in PowerShell.