Skip to navigation
Real World Computing

More XML with PowerShell

Posted on 8 Mar 2007 at 11:36

With help from shiny power, Thomas Lee gets serious with PowerShell, updating the XML order document and using the xml reader class.

Then you add a <command> element for each of the cmdlets that are registered by your snap-in. Within each <command> element, you include:

• a Command-Details node to provide meta-information, such as the cmdlet name and a short cmdlet description.

• a Description node that contains a detailed cmdlet description.

• a Command-Syntax node that describes the syntax. You can specify multiple Command-Syntax item nodes if you have multiple property sets.

• a Command-Parameters node describing the cmdlet's parameters.

• Command-InputTypes node describing input parameters.

• a Command-ReturnValue node that identifies the object type passed back to the command line.

If you're developing your own cmdlets, the Community Extensions project I mentioned earlier provides a Get-CmdletMaml cmdlet that will assist in creating your MAML help file. Get-CmdletMaml uses the .NET reflection capability to look inside your cmdlet's DLL file, find all types with the CmdletAttribute and generate a skeleton MAML Help file. And if you've documented your cmdlet in your code, Get-CmdletMaml can retrieve this documentation text and automatically produce a Help file for your cmdlet.

ShinyPower

I've been using PowerShell for a while now, but I can't always remember all the switches and syntax of every cmdlet. When I was first getting started, I spent a lot of time using the Get-Help cmdlet (still do occasionally!), but you'll quickly find that the PowerShell console window isn't the best or easiest way to browse PowerShell's Help documentation. One neat PowerShell add-on is ShinyPower, shown in the screenshot below, a small application that helps you browse the built-in Help that comes with PowerShell. ShinyPower is a free tool, published under the Microsoft Shared Source Permissive Licence. For more information on ShinyPower or to download it, see www.codeplex.com/ShinyPower.

If you know the structure of an XML document, you can easily manipulate that document with PowerShell; if you don't know its structure, you can still use PowerShell to discover and exploit the structure of the document. The DOM model is simpler to code, but can be less efficient in operation, particularly in memory usage. If you have any comments on this column or can provide suggestions for future columns, feel free to email me at Thomas.Lee@GlobalKnowledge.Net.

1 2 3 4
Subscribe to PC Pro magazine. We'll give you 3 issues for £1 plus a free gift - click here

From around the web

Be the first to comment this article

You need to Login or Register to comment.

(optional)

advertisement

Latest Real World Computing
Latest Blog Posts Subscribe to our RSS Feeds
Latest News Stories Subscribe to our RSS Feeds
Latest ReviewsSubscribe to our RSS Feeds

advertisement

Sponsored Links
 
SEARCH
SIGN UP

Your email:

Your password:

remember me

advertisement


Hitwise Top 10 Website 2010
 
 

PCPro-Computing in the Real World Printed from www.pcpro.co.uk

Register to receive our regular email newsletter at http://www.pcpro.co.uk/registration.

The newsletter contains links to our latest PC news, product reviews, features and how-to guides, plus special offers and competitions.