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.
From around the web
advertisement
- Why virtualisation hasn't slowed the growth of data
- How to make Google AdWords work for your business
- The curse of sloppily written software
- Paying for your crimes with Bitcoin
- Behind the scenes: tech support for Formula 1
- The security risk of fat fingers
- Why Windows Phone 7 isn't quite ready for business
- When will Microsoft stop fiddling with Windows 8?
- Flash down the pan?
- Metro Style apps vs desktop applications
- Chrome's shine getting lost in translation
- BytePac: the cardboard hard disk enclosure
- How tech loosens our grip on reality
- Hokum watch: Safer Internet Day
- Why I'm deleting Adobe from my PC
- Prepare to be patronised: it's Safer Internet Day
- Dear Sony, Samsung and every other tech company in the world: stop trying to be Apple
- Will Apple's Final Cut Pro X update placate the pros?
- Smartr Contacts for iPhone review
- Switching to Office 365's Outlook Web App
- VeriSign slammed for security breach cover-up
- SAP willing to share HANA with Oracle
- Why using a tablet could harm your health
- New RIM boss: no need for drastic change
- RIM founders fall on their swords
- Slow economy helps boost Red Hat revenue by 23%
- Google+ pages get multiple admins
- One in five companies lack card industry compliance
- Oil industry warns hacking attacks could kill
- British workers fear email monitoring
advertisement
