<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Huddled Masses</title>
	<atom:link href="http://huddledmasses.org/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Sun, 14 Mar 2010 04:48:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<item>
		<title>Format-PoshTable &#8211; A Video</title>
		<link>http://huddledmasses.org/format-poshtable-a-video/</link>
		<comments>http://huddledmasses.org/format-poshtable-a-video/#comments</comments>
		<pubDate>Sat, 13 Mar 2010 22:45:07 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1416</guid>
		<description><![CDATA[	       

	Format-PoshTable (PowerBoots + DataGrid from WPFToolkit + PoshConsole) on  ScreenCast or Vimeo (and PoshCode).

	If you can&#8217;t view that (it requires Windows Media Player), you can check it out through Vimeo below.  I apologize for the size and quality of that, I didn&#8217;t read the HD instructions [...]]]></description>
			<content:encoded><![CDATA[	<p><object name="Video" classid="clsid:6BF52A52-394A-11D3-B153-00C04F79FAA6" codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715" standby="Loading Microsoft Windows Media Player components..." type="application/x-oleobject"  width="800" height="665"> <param name="url" value="http://content.screencast.com/users/Jaykul/folders/PowerShell/media/7c2b195b-a944-4a44-94fc-7a2ef5601e0c/Format-PoshTable.wmv"></param> <param name="AutoStart" value="0"></param> <param name="ShowControls" value="true"></param> <param name="uiMode" value="full"></param> <param name="playCount" value="1"></param> <param name="CurrentPosition" value="0"></param> <embed name="Video" type="application/x-mplayer2" src="http://content.screencast.com/users/Jaykul/folders/PowerShell/media/7c2b195b-a944-4a44-94fc-7a2ef5601e0c/Format-PoshTable.wmv" autoStart="0" showcontrols="1" uimode="full" playcount="1" currentposition="0" width="800" height="665"></embed></object></p>

	<p>Format-PoshTable (PowerBoots + <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.datagrid.autogeneratecolumns(VS.100).aspx">DataGrid</a> from <a href="http://wpf.CodePlex.com">WPFToolkit</a> + PoshConsole) on  <a href="http://www.screencast.com/t/ODhhNWE0ZDUt">ScreenCast</a> or <a href="http://vimeo.com/10141844">Vimeo</a> (and <a href="http://poshcode.org/1699">PoshCode</a>).</p>

	<p>If you can&#8217;t view that (it requires Windows Media Player), you can check it out through Vimeo below.  I apologize for the size and quality of that, I didn&#8217;t read the HD instructions ahead of time. Skip to the end for the code <img src='http://huddledmasses.org/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

	<p><object width="800" height="600"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=10141844&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=10141844&amp;server=vimeo.com&amp;show_title=0&amp;show_byline=0&amp;show_portrait=0&amp;color=00ADEF&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="600" height="450"></embed></object><p>A simple demo of some of the capabilities of PowerBoots and PoshConsole in the form of a grid-output function...</p></p>

	<p><script type="text/javascript" src="http://PoshCode.org/embed/1699"></script></p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/format-poshtable-a-video/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
<enclosure url="http://content.screencast.com/users/Jaykul/folders/PowerShell/media/7c2b195b-a944-4a44-94fc-7a2ef5601e0c/Format-PoshTable.wmv" length="8616801" type="video/x-ms-wmv" />
		</item>
		<item>
		<title>A DSL for XML in PowerShell: New-XDocument</title>
		<link>http://huddledmasses.org/a-dsl-for-xml-in-powershell-new-xdocument/</link>
		<comments>http://huddledmasses.org/a-dsl-for-xml-in-powershell-new-xdocument/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 05:52:12 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Atom]]></category>
		<category><![CDATA[DSL]]></category>
		<category><![CDATA[Generator]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Xml]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1406</guid>
		<description><![CDATA[	In July of last year I wrote a PowerShell script with the goal of allowing me to generate XML from PowerShell with a simple markup that would look a little like the resulting XML ... this week I was using that script again, and had a couple of issues that made me go back and [...]]]></description>
			<content:encoded><![CDATA[	<p>In July of last year <a href="http://poshcode.org/1233">I wrote a PowerShell script</a> with the goal of allowing me to generate <span class="caps">XML</span> from PowerShell with a simple markup that would look a little like the resulting <span class="caps">XML</span> ... this week I was using that script again, and had a couple of issues that made me go back and look at the source.</p>

	<p>While I was playing with the source and tweaking things a little bit to improve the way it handles namespaces, I started playing with the idea that I could improve the syntax. At the very least, I thought, I ought to be able to do away with all those &#8220;xe&#8221; aliases&#8230;</p>

	<p>Well, <a href="http://poshcode.org/1682">I was able to</a>. And what&#8217;s more, I managed to dramatically clean up the way namespaces work, and make it so that really, the only ugly part of the syntax is the initial declaration of namespaces! I&#8217;m going to start with two examples, and use them to walk you through the features <img src='http://huddledmasses.org/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

	<h3>Example 1</h3>

	<p>The simplest example I could think of is to list all the files in a folder, with the file size and last modified stamp:</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">string</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$xml</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">New-<span style="font-style: normal;">XDocument</span></span> folder <span style="color: #000066;">-path</span> <span style="color: #660033; font-weight: bold;">$pwd</span> <span style="color: #333;">&#123;</span> <br />
&nbsp; &nbsp;<span style="color: #666699; font-weight: bold;">foreach</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$file</span> <span style="color: #666699; font-weight: bold;">in</span> <span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">ChildItem</span></span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; file <span style="color: #000066;">-Modified</span> <span style="color: #660033; font-weight: bold;">$file</span>.<span style="color: #003366;">LastWriteTimeUtc</span> <span style="color: #000066;">-Size</span> <span style="color: #660033; font-weight: bold;">$file</span>.<span style="color: #003366;">Length</span> <span style="color: #333;">&#123;</span> <span style="color: #660033; font-weight: bold;">$file</span>.<span style="color: #003366;">Name</span> <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
<span style="color: #333;">&#125;</span></div>

	<p>The output of that, when run on my formats folder, looks like this:</p>

	<div class="xml code xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;folder</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;C:\Users\Jaykul\Documents\WindowsPowerShell\formats&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2009-11-07T07:27:00Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;30474&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>CliXml.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2009-11-07T07:27:40.48001Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;14314&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>format.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2010-01-16T21:30:06.0562796Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;18275&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>NppExternalLexers.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2009-03-18T21:28:51.6579351Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;5802&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Recommender.Types.Format.ps1xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;file</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2009-11-07T07:27:40.518029Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;5107&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>types.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/folder<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div>

	<p>You can immediately see what the script does: New-XDocument (which is aliased as &#8216;xml&#8217;) actually generates the root xml node, so the first argument to it is the name of that node, and any other arguments become attributes &#8230; except for the script block. That script block turns into the <em>contents</em> of the node.</p>

	<p>Inside the script block, PowerShell code is parsed as usual, but whenever a command that doesn&#8217;t exist is encountered, it is turned into an xml node! Pretty simple, right?  Of course, if you wanted to create a node with a name that&#8217;s already taken by a PowerShell command, you can just replace <code>file</code> with <code>New-XElement file</code>, or (using aliases) <code>xe &#39;file&#39;</code>, which explicitly creates an xml node with the given name.</p>

	<p>That&#8217;s pretty much it for our first example, so let&#8217;s look at a more complicated example, with multiple namespaces, and deeper nesting.</p>

	<h3>Example 2</h3>

	<p>This time, we&#8217;ll create an Atom document, and we&#8217;ll include some namespace extensions (including a made up one for listing my files as we did above):</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #0066cc; font-style: italic;">New-<span style="font-style: normal;">XDocument</span></span> <span style="color: #333;">&#40;</span><span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>XNamespace<span style="color: #333;">&#93;</span></span><span style="color: #009900;">&quot;http://www.w3.org/2005/Atom&quot;</span><span style="color: #333;">&#41;</span> <span style="color: #66cc66;">+</span> <span style="color: #009900;">&quot;feed&quot;</span><span style="color: #333;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;`<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">-fi</span> <span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>XNamespace<span style="color: #333;">&#93;</span></span><span style="color: #009900;">&quot;http://huddledmasses.org/schemas/FileInfo&quot;</span><span style="color: #333;">&#41;</span> &nbsp; `<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">-dc</span> <span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>XNamespace<span style="color: #333;">&#93;</span></span><span style="color: #009900;">&quot;http://purl.org/dc/elements/1.1&quot;</span><span style="color: #333;">&#41;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; `<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">-</span>$<span style="color: #333;">&#40;</span><span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>XNamespace<span style="color: #333;">&#93;</span></span>::<span style="color: #003366; font-weight: bold;">Xml</span> <span style="color: #66cc66;">+</span><span style="color: #009900;">'lang'</span><span style="color: #333;">&#41;</span> <span style="color: #009900;">&quot;en-US&quot;</span> <span style="color: #000066;">-Encoding</span> <span style="color: #009900;">&quot;UTF-16&quot;</span> &nbsp; &nbsp; &nbsp; &nbsp;`<br />
<span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp;title <span style="color: #333;">&#123;</span><span style="color: #009900;">&quot;Huddled Masses: You can do more than breathe for free...&quot;</span><span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp;link <span style="color: #333;">&#123;</span><span style="color: #009900;">&quot;http://HuddledMasses.org/&quot;</span><span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp;updated <span style="color: #333;">&#123;</span><span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Date</span></span> <span style="color: #000066;">-f</span> u<span style="color: #333;">&#41;</span> <span style="color: #000066;">-replace</span> <span style="color: #009900;">&quot; &quot;</span>,<span style="color: #009900;">&quot;T&quot;</span><span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp;author <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; name <span style="color: #333;">&#123;</span><span style="color: #009900;">&quot;Joel Bennett&quot;</span><span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; uri <span style="color: #333;">&#123;</span><span style="color: #009900;">&quot;http://HuddledMasses.org/&quot;</span><span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp;id <span style="color: #333;">&#123;</span><span style="color: #009900;">&quot;http://HuddledMasses.org/&quot;</span> <span style="color: #333;">&#125;</span><br />
<br />
&nbsp; &nbsp;entry <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; title <span style="color: #333;">&#123;</span><span style="color: #009900;">&quot;A DSL for XML in PowerShell: New-XDocument&quot;</span><span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; link <span style="color: #333;">&#123;</span><span style="color: #009900;">&quot;http://HuddledMasses.org/A-DSL-for-XML-in-PowerShell-New-XDocument/&quot;</span> <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; id <span style="color: #333;">&#123;</span><span style="color: #009900;">&quot;http://HuddledMasses.org/A-DSL-for-XML-in-PowerShell-New-XDocument/&quot;</span> <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; updated <span style="color: #333;">&#123;</span><span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Date</span></span> <span style="color: #cc66cc;">2010</span><span style="color: #66cc66;">/</span>03<span style="color: #66cc66;">/</span>03 <span style="color: #000066;">-f</span> u<span style="color: #333;">&#41;</span> <span style="color: #000066;">-replace</span> <span style="color: #009900;">&quot; &quot;</span>,<span style="color: #009900;">&quot;T&quot;</span><span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; summary <span style="color: #333;">&#123;</span><span style="color: #009900;">&quot;A while back, I posted a simple mini language for generating XML from PowerShell script. However, I was using it the other day, and I really just felt that the markup was ugly, since it was littered with 'xe' marks and such.&quot;</span><span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; link <span style="color: #000066;">-rel</span> license <span style="color: #000066;">-href</span> <span style="color: #009900;">&quot;http://creativecommons.org/licenses/by/3.0/&quot;</span> <span style="color: #000066;">-title</span> <span style="color: #009900;">&quot;CC By-Attribution&quot;</span><br />
&nbsp; &nbsp; &nbsp; dc:rights <span style="color: #333;">&#123;</span> <span style="color: #009900;">&quot;Copyright 2010, Some rights reserved (licensed under the Creative Commons Attribution 3.0 Unported license)&quot;</span> <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; category <span style="color: #000066;">-scheme</span> <span style="color: #009900;">&quot;http://huddledmasses.org/tag/&quot;</span> <span style="color: #000066;">-term</span> <span style="color: #009900;">&quot;xml&quot;</span><br />
&nbsp; &nbsp; &nbsp; category <span style="color: #000066;">-scheme</span> <span style="color: #009900;">&quot;http://huddledmasses.org/tag/&quot;</span> <span style="color: #000066;">-term</span> <span style="color: #009900;">&quot;PowerShell&quot;</span><br />
&nbsp; &nbsp; &nbsp; category <span style="color: #000066;">-scheme</span> <span style="color: #009900;">&quot;http://huddledmasses.org/tag/&quot;</span> <span style="color: #000066;">-term</span> <span style="color: #009900;">&quot;DSL&quot;</span><br />
&nbsp; &nbsp; &nbsp; fi:folder <span style="color: #000066;">-Path</span> <span style="color: #009900;">&quot;~\Formats&quot;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #666699; font-weight: bold;">foreach</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$file</span> <span style="color: #666699; font-weight: bold;">in</span> <span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">ChildItem</span></span> <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Join-<span style="font-style: normal;">Path</span></span> <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Split-<span style="font-style: normal;">Path</span></span> <span style="color: #660033; font-weight: bold;">$profile</span><span style="color: #333;">&#41;</span> Formats<span style="color: #333;">&#41;</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fi:file <span style="color: #000066;">-Created</span> <span style="color: #660033; font-weight: bold;">$file</span>.<span style="color: #003366;">CreationTimeUtc</span> <span style="color: #000066;">-Modified</span> <span style="color: #660033; font-weight: bold;">$file</span>.<span style="color: #003366;">LastWriteTimeUtc</span> <span style="color: #000066;">-Size</span> <span style="color: #660033; font-weight: bold;">$file</span>.<span style="color: #003366;">Length</span> <span style="color: #333;">&#123;</span> <span style="color: #660033; font-weight: bold;">$file</span>.<span style="color: #003366;">Name</span> <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp;<span style="color: #333;">&#125;</span><br />
<span style="color: #333;">&#125;</span> <span style="color: #66cc66;">|</span> <span style="color: #66cc66;">%</span> <span style="color: #333;">&#123;</span> <span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">Declaration</span>.<span style="color: #003366;">ToString</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span>; <span style="color: #660033; font-weight: bold;">$_</span>.<span style="color: #003366;">ToString</span><span style="color: #333;">&#40;</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#125;</span></div>

	<p>There are four things you should notice, in particular:</p>

	<p>First: the initial tag has a [XNamespace] added to it. You can specify a tag name that has a namespace by adding them together this way, or by embedding the namespace in the string like <code>&#34;{http://www.w3.org/2005/Atom}feed&#34;</code> instead.  Either way works. This initial namespace becomes the <strong>default</strong> namespace for the document. If you don&#8217;t specify a namespace on tags later, they automatically belong to that one.</p>

	<p>Second: when you want to add additional namespaces, you can do so with a custom prefix like: <code>-dc ([XNamespace]&#34;http://purl.org/dc/elements/1.1&#34;)</code>, and that prefix (dc) takes on a special meaning. When you want to have a tag later on that is part of that namespace, you just prefix the tag, like <code>dc:rights</code> &#8212;the same way you would in <span class="caps">XML</span>.</p>

	<p>Third: any number of attributes can be specified using the <code>-name value</code> syntax, but anything in a <code>{scriptblock}</code> becomes the content &#8212; and is subject to the same rules as the outer sections.</p>

	<p>Fourth: This generates an XDocument. When you cast an XDocument to string, the xml declaration is left off, so if you want it, you need to manually add it via <code>$XDocument.Declaration</code>.  Incidentally, XDocuments are <strong>not</strong> XMLDocuments, but they <strong>are</strong> trivially castable to them.</p>

	<p>The output of that particular section of New-XDocument is this:</p>

	<div class="xml code xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;feed</span> <span style="color: #000066;">xmlns:dc</span>=<span style="color: #ff0000;">&quot;http://purl.org/dc/elements/1.1&quot;</span> <span style="color: #000066;">xmlns:fi</span>=<span style="color: #ff0000;">&quot;http://huddledmasses.org/schemas/FileInfo&quot;</span> <span style="color: #000066;">xml:lang</span>=<span style="color: #ff0000;">&quot;en-US&quot;</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2005/Atom&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; <br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>http://HuddledMasses.org/<br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2010-03-04T00:44:31Z<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Joel Bennett<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/name<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;uri<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://HuddledMasses.org/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/uri<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/author<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://HuddledMasses.org/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>http://HuddledMasses.org/A-DSL-for-XML-in-PowerShell-New-XDocument/<br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>http://HuddledMasses.org/A-DSL-for-XML-in-PowerShell-New-XDocument/<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/id<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>2010-03-03T00:00:00Z<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/updated<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;summary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>A while back, I posted a simple mini language for generating XML from PowerShell script. However, I was using it the other day, and I really just felt that the markup was ugly, since it was littered with 'xe' marks and such.<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/summary<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;link</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">&quot;license&quot;</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;http://creativecommons.org/licenses/by/3.0/&quot;</span> <span style="color: #000066;">title</span>=<span style="color: #ff0000;">&quot;CC By-Attribution&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;dc:rights<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>Copyright 2010, Some rights reserved (licensed under the Creative Commons Attribution 3.0 Unported license)<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/dc:rights<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> <span style="color: #000066;">scheme</span>=<span style="color: #ff0000;">&quot;http://huddledmasses.org/tag/&quot;</span> <span style="color: #000066;">term</span>=<span style="color: #ff0000;">&quot;xml&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> <span style="color: #000066;">scheme</span>=<span style="color: #ff0000;">&quot;http://huddledmasses.org/tag/&quot;</span> <span style="color: #000066;">term</span>=<span style="color: #ff0000;">&quot;PowerShell&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;category</span> <span style="color: #000066;">scheme</span>=<span style="color: #ff0000;">&quot;http://huddledmasses.org/tag/&quot;</span> <span style="color: #000066;">term</span>=<span style="color: #ff0000;">&quot;DSL&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fi:folder</span> <span style="color: #000066;">path</span>=<span style="color: #ff0000;">&quot;~\Formats&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fi:file</span> <span style="color: #000066;">created</span>=<span style="color: #ff0000;">&quot;2009-11-07T07:27:00Z&quot;</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2009-11-07T07:27:00Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;30474&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>CliXml.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fi:file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fi:file</span> <span style="color: #000066;">created</span>=<span style="color: #ff0000;">&quot;2009-11-07T07:27:40.4529965Z&quot;</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2009-11-07T07:27:40.48001Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;14314&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>format.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fi:file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fi:file</span> <span style="color: #000066;">created</span>=<span style="color: #ff0000;">&quot;2009-02-07T13:56:12Z&quot;</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2010-01-16T21:30:06.0562796Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;18275&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>NppExternalLexers.xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fi:file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fi:file</span> <span style="color: #000066;">created</span>=<span style="color: #ff0000;">&quot;2009-08-09T19:10:06.3647094Z&quot;</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2009-03-18T21:28:51.6579351Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;5802&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>Recommender.Types.Format.ps1xml<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fi:file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;fi:file</span> <span style="color: #000066;">created</span>=<span style="color: #ff0000;">&quot;2009-11-07T07:27:40.4970185Z&quot;</span> <span style="color: #000066;">modified</span>=<span style="color: #ff0000;">&quot;2009-11-07T07:27:40.518029Z&quot;</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">&quot;5107&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>types.xsd<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fi:file<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; &nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/fi:folder<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
&nbsp; <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/category<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span><br />
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/feed<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></div>

	<p>The New-XDocument script itself is on PoshCode in the <a href="http://poshcode.org/1682">Xml Module 4</a> along with a few interesting functions like Select-<span class="caps">XML</span> (which improves over the built-in by being able to ignore namespaces when you write XPath) and Remove-XmlNamespace (which was instrumental in removing namespaces for Select-Xml). There&#8217;s also a  Format-Xml for pretty-printing, and a Convert-Xml for processing <span class="caps">XSL</span> transformations.</p>

	<p>I&#8217;ll probably post some more examples of this in the next week or two, and I really should write some commentary about the function itself, which uses the tokenizer to discover which &#8220;commands&#8221; are really xml nodes &#8230; but for now, I&#8217;ll leave you to enjoy.<h6 class="zemanta-related-title">Related articles by Zemanta</h6><ul class="zemanta-article-ul"><li class="zemanta-article-ul-li"><a href="http://huddledmasses.org/json-from-powershell-but-why/"><span class="caps">JSON</span> from PowerShell (but why?)</a> (huddledmasses.org)</li><li class="zemanta-article-ul-li"><a href="http://apache.sys-con.com/node/1211348">What&#8217;s in a Namespace</a> (apache.sys-con.com)</li><li class="zemanta-article-ul-li"><a href="http://huddledmasses.org/ignoring-namespaces-in-xpath/">Ignoring Namespaces in XPath</a> (huddledmasses.org)</li></ul></p>

<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/c26e9d24-6176-4c07-a3f7-9eb438404e7e/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=c26e9d24-6176-4c07-a3f7-9eb438404e7e" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/a-dsl-for-xml-in-powershell-new-xdocument/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Are you interested in a virtual PowerShell brown-bag event?</title>
		<link>http://huddledmasses.org/are-you-interested-in-a-virtual-powershell-brown-bag-event/</link>
		<comments>http://huddledmasses.org/are-you-interested-in-a-virtual-powershell-brown-bag-event/#comments</comments>
		<pubDate>Wed, 24 Feb 2010 18:30:00 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Brown Bag]]></category>
		<category><![CDATA[Poll]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[User Group]]></category>
		<category><![CDATA[Virtual Group]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/are-you-interested-in-a-virtual-powershell-brown-bag-event/</guid>
		<description><![CDATA[	I just put up a poll on the PowerShell Virtual Group to see if people are interested in a low-planning brown-bag event.

	The initial question is: would you attend a weekly (or monthly) virtual brown-bag lunch if I put one together.

	The idea is that we would start each session with a short collection of interesting links, [...]]]></description>
			<content:encoded><![CDATA[	<p>I just <a href="http://powershellgroup.org/virtual/brown-bag-poll-1">put up a poll</a> on the <a href="http://powershellgroup.org/virtual">PowerShell Virtual Group</a> to see if people are interested in a low-planning brown-bag event.</p>

	<p>The initial question is: would you attend a weekly (or monthly) virtual brown-bag lunch if I put one together.</p>

	<p>The idea is that we would start each session with a short collection of interesting links, tips and tricks, or <a href="http://connect.microsoft.com/PowerShell">connect</a> issues, and then have a presentation or discussion or script club or open-mic session, depending on interest.</p>

	<p>Basically, this is meant to flow, on a week-to-week basis, from script-club to formal user group presentations. </p>

	<p>Some weeks we would have presenters from various local user groups share content they had prepared for their local groups. We would encourage you to take ownership of this time, request topics, and prepare presentations (no matter how short).</p>

	<p>Some weeks we would have an open-format script club using our private pastebin, <span class="caps">IRC</span> channel, and LiveMeeting voice chat.  This time could vary from real-world problem solving to scripting games and &#8220;project Euler&#8221;-style challenges.</p>

	<p>Some weeks we would have open-mic time and solicit feedback for the PowerShell team from anyone who cared to give it. I would make an effort to make sure I wasn&#8217;t the only <span class="caps">MVP</span> there, so you could feel that even if there wasn&#8217;t a Microsoft employee present on a given day, your voice could be heard when you make suggestions or vent frustrations &#8230; </p>

	<p>The point is: the format would vary a bit, and we would adjust it over time to fit whatever works the best within our virtual meeting and time constraints.</p>

	<p>So, what do you think? <a href="http://powershellgroup.org/virtual/brown-bag-poll-1">Are you interested?</a></p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/are-you-interested-in-a-virtual-powershell-brown-bag-event/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Fix Congress First!</title>
		<link>http://huddledmasses.org/fix-congress-first/</link>
		<comments>http://huddledmasses.org/fix-congress-first/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 03:02:16 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1403</guid>
		<description><![CDATA[Image via Wikipedia

	The Democratic leadership in Congress just announced its response to the Supreme Court&#8217;s decision in Citizens United, the case that struck down limits on independent corporate campaign expenditures.

	As Lawrence Lessig put it: hopeless.

	
		The package the Democrats are proposing is filled with ideas that either won&#8217;t work or that, if they worked, would only [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img"><div><dl class="wp-caption alignright"><dt class="wp-caption-dt"><a href="http://commons.wikipedia.org/wiki/Image:USSupremeCourtWestFacade.JPG"><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/USSupremeCourtWestFacade.JPG/300px-USSupremeCourtWestFacade.JPG" alt="West face of the United States Supreme Court b..." title="West face of the United States Supreme Court b..." /></a></dt><dd class="wp-caption-dd zemanta-img-attribution">Image via <a href="http://commons.wikipedia.org/wiki/Image:USSupremeCourtWestFacade.JPG">Wikipedia</a></dd></dl></div></div>

	<p>The Democratic leadership in Congress just announced its response to the Supreme Court&#8217;s decision in <a href="http://en.wikipedia.org/wiki/Citizens_United_v._Federal_Election_Commission">Citizens United</a>, the case that struck down limits on independent corporate campaign expenditures.</p>

	<p>As Lawrence Lessig put it: hopeless.</p>

	<blockquote>
		<p>The package the Democrats are proposing is filled with ideas that either won&#8217;t work or that, if they worked, would only invite the Supreme Court to strike again.</p>
	</blockquote>

	<blockquote>
		<p>Congress had a chance to do something real here, but rather than supporting a bold reform that would make our democracy function better, they failed; they changed nothing. And as a result, our representatives&#8217; dependency on campaign funders &#8212; the central corrupting force acting on our government &#8212; will continue for another day. </p>
	</blockquote>

	<p>We all knew that&#8217;s what would happen, of course. Members of Congress don&#8217;t have much incentive to buck a systems that keeps their campaign coffers full. Here&#8217;s what <a class="zem_slink" href="http://en.wikipedia.org/wiki/Change_Congress" title="Change Congress" rel="wikipedia">Change Congress</a> has to say on the matter on their <a href="http://fixcongressfirst.org">Fix Congress First!</a> website.</p>

	<blockquote>
		<p>The Fair Elections Now Act is the reform we need, and we still have the chance to push Congress to pass it. So far, 135 Members of the House have signed on as co-sponsors, but we must continue to urge all of our representatives to support this crucial bill. You can use our simple tool to email your members of Congress and tell them that this issue won&#8217;t fly under the radar in 2010: <a href="http://fixcongressfirst.org/email">http://fixcongressfirst.org/email</a></p>
	</blockquote>

	<blockquote>
		<p>If the Democratic Party wants to lead, then they need to show us they&#8217;re ready to lead. And if the Republican Party wants to rise back to power, they need to prove they&#8217;d use that power to enact the will of the people. </p>
	</blockquote>

	<p>Incidentally, I think you should <a href="http://www.fixcongressfirst.org/blog/entry/breaking-congresss-response-to-citizens-united/#reactions">read professor Lawrence Lessig&#8217;s response</a> to the changes that the Democratic leadership is proposing.  The bottom line is that these changes won&#8217;t help: they won&#8217;t make Members of Congress any less dependent on special interests and corporate fundraising, and they almost certainly won&#8217;t stand up to scrutiny by the current Supreme Court.</p>

<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/c99e7998-be15-46e6-8417-595ecfb5e0d8/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=c99e7998-be15-46e6-8417-595ecfb5e0d8" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/fix-congress-first/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UPNYPUG &#8211; Rochester PowerShell UserGroup Meeting Wednesday</title>
		<link>http://huddledmasses.org/upnypug-rochester-powershell-usergroup-meeting-wednesday/</link>
		<comments>http://huddledmasses.org/upnypug-rochester-powershell-usergroup-meeting-wednesday/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 15:06:53 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[GettingStarted]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[PowerShellGroup]]></category>
		<category><![CDATA[Presentations]]></category>
		<category><![CDATA[Rochester New York]]></category>
		<category><![CDATA[UserGroup]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1397</guid>
		<description><![CDATA[Image via Wikipedia

	I&#8217;ve written this up on the new website for our Rochester PowerShell group and on the old blog, and on UGSS Facebook and Twitter &#8230; and now that there&#8217;s only two days left, it&#8217;s time to mention it again, on my blog  

	This Wednesday, January 20, 2010 &#8211; 6:00pm

	It&#8217;s a new year, [...]]]></description>
			<content:encoded><![CDATA[<div class="zemanta-img"><div><dl class="wp-caption alignright"><dt class="wp-caption-dt"><a href="http://en.wikipedia.org/wiki/Image:Roc_032c.JPG"><img src="http://upload.wikimedia.org/wikipedia/en/thumb/5/55/Roc_032c.JPG/300px-Roc_032c.JPG" alt="A portion of Rochester's skyline, looking nort..." title="A portion of Rochester's skyline, looking nort..." /></a></dt><dd class="wp-caption-dd zemanta-img-attribution">Image via <a href="http://en.wikipedia.org/wiki/Image:Roc_032c.JPG">Wikipedia</a></dd></dl></div></div>

	<p>I&#8217;ve written this up on the new website for our <a href="http://powershellgroup.org/rochester-ny">Rochester PowerShell group</a> and on the <a href="http://upnypug.wordpress.com">old blog</a>, and on <a href="http://www.usergroupsupportservices.com/UserGroupInformation.ugss?ActiveID=5048">UGSS</a> Facebook and Twitter &#8230; and now that there&#8217;s only two days left, it&#8217;s time to mention it again, on my blog <img src='http://huddledmasses.org/wordpress/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>

	<h3><a href="http://powershellgroup.org/rochester-ny/events/january-20-2010">This Wednesday, January 20, 2010 &#8211; 6:00pm</a></h3>

	<p>It&#8217;s a new year, and a new opportunity to get started with PowerShell. With the new year, we&#8217;re going to put a renewed focus on trying to make our meetings valuable to everyone. With that in mind, the first Rochester meeting of the upstate New York PowerShell users group in 2010 will feature two separate presentations:</p>

	<h5>Getting Started: The PowerShell Pipeline (100 Level)</h5>

	<ul>
		<li>Different types of commands in PowerShell</li>
		<li>Variable assignment and Pipeline arguments</li>
		<li>Understanding the Pipe</li>
		<li>Why PowerShell&#8217;s pipeline is different</li>
	</ul>
	<ul>
		<li>Exploiting pipelines for fun and profit</li>
	</ul>

	<h5>Creating PowerShell script Modules (300 Level)</h5>

	<ul>
		<li>Turning your script or function into a module</li>
		<li>What makes a function an &#8220;advanced function&#8221;</li>
		<li>Providing in-line help for functions</li>
		<li>Controlling what functions and variables your module exports</li>
	</ul>
	<ul>
		<li>Why you should use Module Metadata files</li>
	</ul>

	<p>Everyone is welcome, from beginners to pros! Bring a friend and introduce them to PowerShell. As always, our meeting will be at New Horizons&#8217; in Henrietta, 50 Methodist Hill Drive, Suite 50.</p>

	<p>In order to keep things on time, we&#8217;ll be starting our presentations at 6:30 exactly, after a short pizza, wings, and networking time starting at 6pm. We only ask that if you can come early for the food you <strong>let us know ahead of time</strong> and come ready to pitch in a few dollars to help cover the cost.</p>

	<p>PS: There will be swag. We have several books, an Arc Mouse, and copies of Windows 7 and Office 2007 to give away&#8230;</p>

<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/cf741a5f-0b2b-4dcc-a258-5d0f0738e972/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=cf741a5f-0b2b-4dcc-a258-5d0f0738e972" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/upnypug-rochester-powershell-usergroup-meeting-wednesday/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Module Manifests Tip: allowed cmdlets and variables</title>
		<link>http://huddledmasses.org/powershell-module-manifests-tip-allowed-cmdlets-and-variables/</link>
		<comments>http://huddledmasses.org/powershell-module-manifests-tip-allowed-cmdlets-and-variables/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 02:56:58 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Manifest]]></category>
		<category><![CDATA[Metadata]]></category>
		<category><![CDATA[Modules]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[Windows 7]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1394</guid>
		<description><![CDATA[	I was under the impression that module manifests allow only DATA stuff. In fact, if you try to use cmdlets or variables in them, you get the usual Data-language errors, like this:

	Import-Module : The module manifest &#8216;C:\Modules\Test\Test.psd1&#8217; could not be processed because it is not a valid PowerShell restricted language file. Please remove the elements [...]]]></description>
			<content:encoded><![CDATA[	<p>I was under the impression that module manifests allow only <span class="caps">DATA</span> stuff. In fact, if you try to use cmdlets or variables in them, you get the usual Data-language errors, like this:</p>

	<p><code style="color: red; margin-left: 10px;"></code><p>Import-Module : The module manifest &#8216;C:\Modules\Test\Test.psd1&#8217; could not be processed because it is not a valid PowerShell restricted language file. Please remove the elements that are not permitted by the restricted language: The command &#8216;Get-ChildItem&#8217; is not in allowed in restricted language mode or a Data section.</p><br />
<p>Import-Module : The module manifest &#8216;C:\Modules\Test\Test.psd1&#8217; could not be processed because it is not a valid PowerShell restricted language file. Please remove the elements that are not permitted by the restricted language: A variable that cannot be referenced in restricted language mode or a Data section is being referenced. Variables that can be referenced include the following: $PSCulture, $PSUICulture, $true, $false, and $null.</p></p>

	<p><span class="caps">BUT</span> <span class="caps">THEN</span> I came across this in the Windows 7 built-in BitsTransfer module:</p>

	<p>RequiredAssemblies=Join-Path $psScriptRoot &#8220;Microsoft.BackgroundIntelligentTransfer.Management.Interop.dll&#8221;</p>

	<p><span class="caps">AND</span> IT WORKS?!</p>

	<p>Well, that&#8217;s very weird, because <code>Join-Path</code> is certainly not allowed in a normal &#8220;restricted language&#8221; file, and (as you can tell from above) neither is <code>$PsScriptRoot</code> &#8212; in fact, as far as I know, you shouldn&#8217;t have to do that at all, since RequiredAssemblies knows enough to look in your module folder&#8230; but nevermind that, why does it work?</p>

	<h3>The Rest of the Story</h3>

	<p>So I went digging, and it turns out that although they are parsed as Restricted Language (like a &#8220;data section,&#8221; see <a href="http://technet.microsoft.com/en-us/library/dd347678.aspx">about_Data_Sections</a>), module manifests are allowed extra cmdlets:  &#8220;Import-LocalizedData&#8221;, &#8220;ConvertFrom-StringData&#8221;, &#8220;Write-Host&#8221;, &#8220;Out-Host&#8221;, &#8220;Join-Path&#8221; and even special variables that aren&#8217;t normally allowed in data sections: specifically $PsScriptRoot which is the ModuleBase (the parent folder of the psd1) and environment variables ($Env:), plus the usual $PSCulture, $PSUICulture, and of course $true, $false, and $null.</p>

	<p>However, although you can use those variables, you can&#8217;t embed them in strings, so if you wanted to use <code>$Env:Windir</code> or <code>$Env:Temp</code> as part of a path (for instance), you need to take advantage of the availability of <code>Join-Path</code>.</p>

	<p>Now, I can&#8217;t find this documented anywhere (although I did add it to the <a href="http://msdn.microsoft.com/en-us/library/dd878337%28VS.85%29.aspx">module manifest documentation on MSDN</a>), but it&#8217;s true, nonetheless &#8212; you&#8217;ll just have to trust me <img src='http://huddledmasses.org/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Yeah, PowerShell is starting to drive me crazy again.</p>

<h6 class="zemanta-related-title">Related articles by Zemanta</h6><ul class="zemanta-article-ul"><li class="zemanta-article-ul-li"><a href="http://huddledmasses.org/a-question-about-powershell-module-manifests/">A question about PowerShell Module Manifests</a> (huddledmasses.org)</li><li class="zemanta-article-ul-li"><a href="http://huddledmasses.org/another-module-manifest-gotcha/">Another Module Manifest Gotcha</a> (huddledmasses.org)</li></ul>

<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/4ca92c55-78cf-49bf-9cd4-a02adb78774d/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=4ca92c55-78cf-49bf-9cd4-a02adb78774d" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/powershell-module-manifests-tip-allowed-cmdlets-and-variables/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Another Module Manifest Gotcha</title>
		<link>http://huddledmasses.org/another-module-manifest-gotcha/</link>
		<comments>http://huddledmasses.org/another-module-manifest-gotcha/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 03:42:36 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Error message]]></category>
		<category><![CDATA[Globally Unique Identifier]]></category>
		<category><![CDATA[Import-Module]]></category>
		<category><![CDATA[Metadata]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[RequiredModules]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1386</guid>
		<description><![CDATA[	Shay Levy, ScriptFanatic, wrote about the PowerShellHostVersion on his blog this morning, explaining how it is not a field you should use in your module manifests.

	Of course, there&#8217;s an exception: if your module is dependent on a specific host.  For instance, if you&#8217;ve written a module for PoshConsole which exploits the WpfHost display features [...]]]></description>
			<content:encoded><![CDATA[	<p>Shay Levy, ScriptFanatic, wrote <a href="http://blogs.microsoft.co.il/blogs/scriptfanatic/archive/2010/01/14/module-manifest-gotcha.aspx">about the PowerShellHostVersion</a> on his blog this morning, explaining how it is <strong>not</strong> a field you should use in your <a href="http://msdn.com/library/dd878337.aspx">module manifests</a>.</p>

	<p>Of course, there&#8217;s an exception: if your module is dependent on a specific host.  For instance, if you&#8217;ve written a module for <a href="http://poshconsole.codeplex.com">PoshConsole</a> which exploits the WpfHost display features or the BgHost hotkeys feature &#8230; or if you&#8217;ve written <a href="http://code.msdn.microsoft.com/PowerShellPack">ISEPack</a> based on the menu and script-editor features of PowerShell <span class="caps">ISE</span>), then it makes sense to specify the <strong>PowerShellHostName</strong> and the <strong>PowerShellHostVersion</strong> together.  However, if you aren&#8217;t taking a dependency on a specific host &#8230; you should definitely <strong>never</strong> specify PowerShellHostVersion by itself.</p>

	<h3>RequiredModules</h3>

	<p>I&#8217;ve got another one that I think you should not use. PowerShell has several ways of specifying prerequisites for your modules, such as assemblies that should be loaded, modules that must be nested, etc. In every case <strong>except</strong> RequiredModules, PowerShell will actually import those things for you.</p>

	<p>That is, if you specify that you RequiredAssemblies = &#8220;System.Windows.Forms&#8221; it will automatically load it. If you specify NestedModules = &#8220;BitsTransfer&#8221; it will automatically load that. But if you specify RequiredModules = &#8220;BitsTransfer&#8221; you&#8217;re sore out of luck.</p>

	<p>Not only does PowerShell not load them for you, it doesn&#8217;t give you all the information you need to load them when it fails. For example, consider that you have a module called &#8220;ReallyRequired&#8221; and one called &#8220;TestModule&#8221; which requires ReallyRequired.  It&#8217;s metadata file is very simple, it looks like this:</p>

	<div class="posh code posh" style="font-family:monospace;">@<span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; Author<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;Joel Bennett&quot;</span><br />
&nbsp; &nbsp; ModuleToProcess<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;TestModule.psm1&quot;</span>; ModuleVersion<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;1.0.0.0&quot;</span><br />
&nbsp; &nbsp; RequiredModules<span style="color: #66cc66;">=</span>@<span style="color: #333;">&#123;</span>ModuleName<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;ReallyRequired&quot;</span>;GUID<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;84b5ab08-3620-4f72-bffd-44d2a6bb506d&quot;</span>; ModuleVersion<span style="color: #66cc66;">=</span><span style="color: #009900;">&quot;2.5.0.0&quot;</span><br />
<span style="color: #333;">&#125;</span></div>

	<p>Before we try to import it, we might try to check which modules it requires, and since it doesn&#8217;t appear to require any, we&#8217;ll go ahead and import it:</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #333;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #333;">&#93;</span>: <span style="color: #0066cc; font-style: italic;">get-<span style="font-style: normal;">module</span></span> <span style="color: #000066;">-list</span> TestModule <span style="color: #66cc66;">|</span> <span style="color: #660033;">Select</span> RequiredModule<br />
<br />
RequiredModules &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #66cc66;">---------------</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: #333;">&#123;</span><span style="color: #333;">&#125;</span><br />
<br />
<span style="color: #333;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #333;">&#93;</span>: <span style="color: #0066cc; font-style: italic;">Import-<span style="font-style: normal;">Module</span></span> TestModule<br />
<br />
<span style="color: #0066cc; font-style: italic;">Import-<span style="font-style: normal;">Module</span></span> : The required module <span style="color: #009900;">'ReallyRequired'</span> <span style="color: #333399; font-weight: bold; font-style: italic;">is</span> <span style="color: #333399; font-weight: bold; font-style: italic;">not</span> loaded. <span style="color: #003366;">Load</span> the module <span style="color: #333399; font-weight: bold; font-style: italic;">or</span> remove the module <span style="color: #666699; font-weight: bold;">from</span> <span style="color: #009900;">'RequiredModules'</span> <span style="color: #666699; font-weight: bold;">in</span> the file <span style="color: #009900;">'C:\Users\Joel\Documents\WindowsPowerShell\Modules\TestModule\TestModule.psd1'</span>.</div>

	<p>Apparently, there&#8217;s just no way to tell which module(s) you need to preload (or even whether there are any) until you get an error message. You might think you could just write a script to test for that error and then run <code>Import-Module ReallyRequired</code> &#8230; but what you don&#8217;t know is that after you load your copy of the ReallyRequired module:</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #333;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #333;">&#93;</span>: ImportModule TestModule<br />
<br />
<span style="color: #0066cc; font-style: italic;">Import-<span style="font-style: normal;">Module</span></span> : The required module <span style="color: #009900;">'ReallyRequired'</span> with version <span style="color: #009900;">'2.5.0.0'</span> <span style="color: #333399; font-weight: bold; font-style: italic;">is</span> <span style="color: #333399; font-weight: bold; font-style: italic;">not</span> loaded. <span style="color: #003366;">Load</span> the module <span style="color: #333399; font-weight: bold; font-style: italic;">or</span> remove the module <span style="color: #666699; font-weight: bold;">from</span> <span style="color: #009900;">'RequiredModules'</span> <span style="color: #666699; font-weight: bold;">in</span> the file <span style="color: #009900;">'C:\Users\Joel\Documents\WindowsPowerShell\Modules\TestModule\TestModule.psd1'</span>.</div>

	<p>If you&#8217;re like me, right now you&#8217;re tearing out your hair wondering why the error message didn&#8217;t tell you that in the first place. Then you have to go off and try to find a newer version of your RequiredModules. And that&#8217;s not even the crazy thing! The crazy thing is, if you find the wrong one, you could still get a message about the <span class="caps">GUID</span> not matching next. <img src='http://huddledmasses.org/wordpress/wp-includes/images/smilies/icon_eek.gif' alt='8-O' class='wp-smiley' /> </p>

	<p>So yeah, RequiredModules is really unlikely to be helpful right now. You&#8217;re better off just putting an <code>Import-Module ReallyRequired -version 2.5 -ErrorAction Stop</code> at the top of you script module (although that won&#8217;t help you if you&#8217;re writing a binary cmdlet module).</p>

	<h3>Some good news</h3>

	<p>This is just one of the things that the new PoshCode is being designed to address, so I&#8217;ll be blogging more about this shortly, but for now, you can use this function to list RequiredModules:</p>

	<div class="posh code posh" style="font-family:monospace;"><span style="color: #666699; font-weight: bold;">function</span> <span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">RequiredModules</span></span> <span style="color: #333;">&#123;</span><br />
<span style="color: #666699; font-weight: bold;">Param</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$Path</span><span style="color: #333;">&#41;</span><br />
<span style="color: #660033; font-weight: bold;">$dataSource</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">Get-<span style="font-style: normal;">Content</span></span> <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Resolve-<span style="font-style: normal;">Path</span></span> <span style="color: #660033; font-weight: bold;">$Path</span><span style="color: #333;">&#41;</span> <span style="color: #000066;">-delim</span> <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">char</span><span style="color: #333;">&#93;</span></span><span style="color: #cc66cc;">0</span><br />
<br />
<span style="color: #666666; font-style: italic;">## We are ONLY going to &quot;Tokenize&quot; this to make sure there isn't an extra &quot;}&quot; which could lead to an exploit:</span><br />
&nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$null</span> <span style="color: #66cc66;">=</span> <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Management.<span style="color: #003366;">Automation</span>.<span style="color: #003366;">PSParser</span><span style="color: #333;">&#93;</span></span>::<span style="color: #003366;">Tokenize</span><span style="color: #333;">&#40;</span><span style="color: #009900;">&quot;&quot;</span>, <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">ref</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$null</span><span style="color: #333;">&#41;</span> &nbsp;<span style="color: #666666; font-style: italic;"># work around a PowerShell BUG</span><br />
&nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$ParseErrors</span> <span style="color: #66cc66;">=</span> <span style="color: #0066cc; font-style: italic;">New-<span style="font-style: normal;">Object</span></span> <span style="color: #009900;">&quot;System.Collections.ObjectModel.Collection[System.Management.Automation.PSParseError]&quot;</span><br />
&nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$global</span>:tokens <span style="color: #66cc66;">=</span> <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span>Management.<span style="color: #003366;">Automation</span>.<span style="color: #003366;">PSParser</span><span style="color: #333;">&#93;</span></span>::<span style="color: #003366;">Tokenize</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$dataSource</span>, <span style="color: #003366; font-weight: bold;"><span style="color: #333;">&#91;</span><span style="color: #003366; font-weight: bold;">ref</span><span style="color: #333;">&#93;</span></span><span style="color: #660033; font-weight: bold;">$ParseErrors</span><span style="color: #333;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #666699; font-weight: bold;">if</span><span style="color: #333;">&#40;</span><span style="color: #660033; font-weight: bold;">$ParseErrors</span>.<span style="color: #003366;">Count</span> <span style="color: #000066;">-gt</span> <span style="color: #cc66cc;">0</span><span style="color: #333;">&#41;</span> <span style="color: #333;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #660033; font-weight: bold;">$ParseErrors</span> <span style="color: #66cc66;">|</span> <span style="color: #66cc66;">%</span><span style="color: #333;">&#123;</span> <span style="color: #666699; font-weight: bold;">throw</span> <span style="color: #009900;">&quot;$($_.Message)<span style="color: #000099; font-weight: bold;">`n</span>$File at line:$($_.Token.StartLine) char:$($_.Token.Start)&quot;</span> <span style="color: #333;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #333;">&#125;</span><br />
<span style="color: #660033; font-weight: bold;">$dataSource</span> <span style="color: #66cc66;">=</span> <span style="color: #660033; font-weight: bold;">$dataSource</span> <span style="color: #000066;">-replace</span> <span style="color: #009900;">&quot;<span style="color: #000099; font-weight: bold;">`n</span># SIG #&quot;</span>,<span style="color: #009900;">&quot;<span style="color: #000099; font-weight: bold;">`n</span> # SIG #&quot;</span><br />
<span style="color: #666699; font-weight: bold;">return</span> <span style="color: #333;">&#40;</span><span style="color: #0066cc; font-style: italic;">Invoke-<span style="font-style: normal;">Expression</span></span> <span style="color: #009900;">&quot;DATA {<span style="color: #000099; font-weight: bold;">`n</span> $dataSource <span style="color: #000099; font-weight: bold;">`n</span>}&quot;</span><span style="color: #333;">&#41;</span>.<span style="color: #003366;">RequiredModules</span><br />
<span style="color: #333;">&#125;</span></div>

<h6 class="zemanta-related-title">Related articles by Zemanta</h6><ul class="zemanta-article-ul"><li class="zemanta-article-ul-li"><a href="http://huddledmasses.org/a-question-about-powershell-module-manifests/">A question about PowerShell Module Manifests</a> (huddledmasses.org)</li></ul>

<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/bf32d64f-fae9-4f34-ab85-385a6242e5ba/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=bf32d64f-fae9-4f34-ab85-385a6242e5ba" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/another-module-manifest-gotcha/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A question about PowerShell Module Manifests</title>
		<link>http://huddledmasses.org/a-question-about-powershell-module-manifests/</link>
		<comments>http://huddledmasses.org/a-question-about-powershell-module-manifests/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 05:44:23 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[CPAN]]></category>
		<category><![CDATA[Metadata]]></category>
		<category><![CDATA[Module Manifest]]></category>
		<category><![CDATA[PoshCode]]></category>
		<category><![CDATA[Windows PowerShell]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1382</guid>
		<description><![CDATA[	So, I&#8217;m building the next PoshCode around modules, with CPAN as my model &#8230; 

	Scripts are still there, but they&#8217;re still basically done the way they are now: you just upload a single file. 

	Modules, however, will be treated specially. You&#8217;ll have to have an account to upload, but you&#8217;ll be able to just upload [...]]]></description>
			<content:encoded><![CDATA[	<p>So, I&#8217;m building the next PoshCode around modules, with <span class="caps">CPAN</span> as my model &#8230; </p>

	<p>Scripts are still there, but they&#8217;re still basically done the way they are now: you just upload a single file. </p>

	<p>Modules, however, will be treated specially. You&#8217;ll have to have an account to upload, but you&#8217;ll be able to just upload a .zip file of your module folder using your login and not fill in any other forms. Our system will take care of parsing the metadata out of the <a href="http://msdn.microsoft.com/en-us/library/dd878337%28VS.85%29.aspx">manifest</a> in your module folder.</p>

	<p>The problem is that I need a little data that isn&#8217;t a part of the <a href="http://msdn.microsoft.com/en-us/library/dd878337%28VS.85%29.aspx">standard module manifest</a> format&#8230; and I can&#8217;t add it because PowerShell won&#8217;t load a module with extra fields in the manifest metadata hashtable: https://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=421837 &#8212; My request was closed &#8220;by design&#8221; early in the beta cycle and I wasn&#8217;t able to convince them to rethink that.</p>

	<p>At a minimum, PoshCode <strong>requires</strong> a <span class="caps">LICENSE</span> field, and a <span class="caps">CATEGORY</span> field (think of the categories on <span class="caps">CPAN</span> or TechNet Script Center).</p>

	<p>So I&#8217;m having an informal poll. (you&#8217;ll have to &#8220;vote&#8221; by commenting or tweeting to me, because I want more than just &#8220;I choose A&#8221;).</p>

	<p>Which option do you prefer, or can you think of a better way:</p>

	<h4>Require the License and Category to be part of the <span class="caps">PRIVATEDATA</span> field in the standard manifest</h4>

	<p>This might require authors to rewrite parts of their modules, because we&#8217;d be forcing PrivateData to be a Hashtable, and to contain keys that they don&#8217;t need in the module.</p>

	<p>Some existing modules use an array in PrivateData, or even a simple string, rather than a Hashtable. However, it&#8217;s not a <strong>huge</strong> difference, and might be the cleanest method: it wouldn&#8217;t require you to manage a second file of data, and the additional data will be easily available to users and scripts via the standard Get-Module output.</p>

	<h4>Add a &#8220;doc comment&#8221; system for Module manifest files.</h4>

	<p>The upside of this is that PoshCode wants to create module-level documentation anyway. If we use documentation comments like those used on functions we would be able to just create our own standard for them, and add any extra fields we need. It would be guaranteed not to conflict with anything you&#8217;re already doing, and in addition to missing metadata, you could have some module-level documentation beyond just the Description field of the metadata.  </p>

	<p>The problem with this is that there&#8217;s no built-in way to parse that, and doing so isn&#8217;t trivial, so you would need to just read it on our website, or read the source of the file, or have our PoshCode cmdlets in order to make any sense of it once you had a module on your system. It doesn&#8217;t integrate with PowerShell in any meaningful way.</p>

	<h4>Embed the extra data right in the manifest hashtable, using a special comment to hide it from Get-Module</h4>

	<p><code lang=&#8220;posh&#8221;<br />
@{<br />
author=&#8220;Joel Bennett&#8221;<br />
description=&#8220;My latest crazy module&#8221;<br />
<#!PoshCode<br />
License=&#8220;Ms-PL&#8221;<br />
Category=&#8220;WPF&#8221;,&#8220;GUI&#8221;,&#8220;Toolkit&#8221;
#><br />
CompanyName=&#8220;Huddled Masses&#8221;<br />
...<br />
}<br />
</code></p>

	<p>I like this because it&#8217;s fairly trivial for us to strip out the comment and just turn that into a plain-old <span class="caps">DATA</span> section.  It also lends itself to reminding the PowerShell team that these fields are missing, and maintains the existing simple syntax of the manifest.  </p>

	<p>The problem here is, again, that the data doesn&#8217;t appear using any of the standard PowerShell tools &#8212; but getting it out is significantly easier than getting out document comments&#8230;</p>

	<h4>Require a separate &#8220;ReadMe.psd1&#8221; (or &#8220;PoshCode.pds1&#8221; or &#8220;Metadata.psd1&#8221;) metadata file</h4>

	<p>You could start with a copy of your module manifest, and then add the extra stuff that PoshCode needs. This would be nice because we would be able to add any extra fields we wanted as mandatory members, and we could include the &#8220;documentation&#8221; stuff I mentioned earlier&#8230;</p>

	<p>But the downside is that it would be a third file (second manifest) that authors would have to maintain and keep current.</p>

	<p>Any thoughts? Suggestions? </p>

	<p>I&#8217;ve put some further thoughts <a href="http://wiki.poshcode.org/PoshCode_Project/CPAN_and_PoshCode_vNext">about CPAN</a> and the <a href="http://wiki.poshcode.org/PoshCode_Project/Module_Upload_System">data problem</a> on the wiki.</p>

<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/afd48ed4-ce64-4ce4-a1a3-9d7daffc69ed/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=afd48ed4-ce64-4ce4-a1a3-9d7daffc69ed" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/a-question-about-powershell-module-manifests/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Announcing PowerShellGroup.org &#8211; A home for PowerShell User Groups</title>
		<link>http://huddledmasses.org/announcing-powershellgroup-org-a-home-for-powershell-user-groups/</link>
		<comments>http://huddledmasses.org/announcing-powershellgroup-org-a-home-for-powershell-user-groups/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 04:49:20 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Computers and Internet]]></category>
		<category><![CDATA[User Group]]></category>
		<category><![CDATA[WebHosting]]></category>
		<category><![CDATA[Windows PowerShell]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1379</guid>
		<description><![CDATA[	I&#8217;ve just created PowerShellGroup.org &#8212; a new site for PowerShell user groups (starting with: Rochester, Syracuse, Atlanta, Ottawa and of course, the Virtual Group).

	It&#8217;s open to any PowerShell user groups or script clubs. If you&#8217;re running a PowerShell user group and want simple web-hosting with:
	
		top-of-the-site billing for your group (with a url like http://powershellgroup.org/rochester-ny )
		group [...]]]></description>
			<content:encoded><![CDATA[	<p>I&#8217;ve just created <a href="http://PowerShellGroup.org">PowerShellGroup.org</a> &#8212; a new site for PowerShell user groups (starting with: <a href="http://PowerShellGroup.org/rochester-ny">Rochester</a>, <a href="http://PowerShellGroup.org/syracuse-ny">Syracuse</a>, <a href="http://PowerShellGroup.org/atlanta-ga">Atlanta</a>, <a href="http://PowerShellGroup.org/ottawa-ca">Ottawa</a> and of course, the <a href="http://powershellgroup.org/virtual">Virtual Group</a>).</p>

	<p>It&#8217;s open to any PowerShell user groups or script clubs. If you&#8217;re running a PowerShell user group and want simple web-hosting with:
	<ul>
		<li>top-of-the-site billing for your group (with a url like http://powershellgroup.org/rochester-ny )</li>
		<li>group signups</li>
		<li>events, calendars and event signups (including sending out <span class="caps">RSVP</span> emails to your group), and email reminders of events </li>
		<li>a semi-private group section for posting notices, wiki pages, etc.</li>
	</ul>
	<ul>
		<li>optional twitter notification for your posts</li>
	</ul><br />
and so on&#8230;</p>

	<p>Just let me know who you are after you sign up on the site, and I can set you up with &#8220;group administrator&#8221; rights.</p>

	<p>Also, if you have your own web hosting for your user group, but would like to be listed on our site, we can handle that too <img src='http://huddledmasses.org/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>

<div class="zemanta-pixie"><a class="zemanta-pixie-a" href="http://reblog.zemanta.com/zemified/bea06667-02a0-465b-92a4-dd09739c4320/" title="Reblog this post [with Zemanta]"><img class="zemanta-pixie-img" src="http://img.zemanta.com/reblog_e.png?x-id=bea06667-02a0-465b-92a4-dd09739c4320" alt="Reblog this post [with Zemanta]" /></a><span class="zem-script more-related pretty-attribution"><script type="text/javascript" src="http://static.zemanta.com/readside/loader.js" defer="defer"></script></span></div>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/announcing-powershellgroup-org-a-home-for-powershell-user-groups/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>The Virtual PowerShell Group</title>
		<link>http://huddledmasses.org/the-virtual-powershell-group/</link>
		<comments>http://huddledmasses.org/the-virtual-powershell-group/#comments</comments>
		<pubDate>Mon, 04 Jan 2010 20:39:00 +0000</pubDate>
		<dc:creator>Joel 'Jaykul' Bennett</dc:creator>
				<category><![CDATA[Huddled]]></category>
		<category><![CDATA[Discussion Groups]]></category>
		<category><![CDATA[Internet Relay Chat]]></category>
		<category><![CDATA[IRC]]></category>
		<category><![CDATA[PowerShell]]></category>
		<category><![CDATA[User Group]]></category>

		<guid isPermaLink="false">http://huddledmasses.org/?p=1369</guid>
		<description><![CDATA[	

	This is old news and new news &#8230; but I figured it&#8217;s about time I break it on my blog, since it was mostly my doing (and since my Northeast Developer Evangelist Jim O&#8217;Neil already mentioned it on his blog).

	We have created an official Virtual PowerShell Group (official, in the sense that it&#8217;s recognized by [...]]]></description>
			<content:encoded><![CDATA[	<p><img src="http://powershellgroup.org/sites/default/files/garland_logo.png" class="zemanta-pixie-img" align="right" alt="" width="199" height="128" /></p>

	<p>This is old news and new news &#8230; but I figured it&#8217;s about time I break it on my blog, since it was mostly my doing (and since my Northeast Developer Evangelist <a href="http://blogs.msdn.com/jimoneil/archive/2010/01/04/powershell-virtually.aspx">Jim O&#8217;Neil already mentioned it on his blog</a>).</p>

	<p>We have created an official Virtual PowerShell Group (official, in the sense that it&#8217;s recognized by Microsoft&#8217;s <a href="https://www.usergroupsupportservices.com/UserGroupInformation.ugss?UGName=VirtualPowerShellGroup">User Group Support Services</a> out of the unofficial <a href="irc://irc.freenode.net/PowerShell">#PowerShell channel on irc.freenode.net</a> and have created <a href="http://PowerShellGroup.org/virtual">a website to support it</a> including a page where you can <a href="http://powershellgroup.org/virtual/live">join us online via web-based chat</a> any time you like.</p>

	<p>Of course, this isn&#8217;t <em>exactly</em> headline news: The #PowerShell <span class="caps">IRC</span> channel has been around for years and has always been helpful and polite.  What&#8217;s new is that we are officially a User Group, and have swag to give away (more on that later)!  We&#8217;re hoping that this will help some of you justify joining us, and using <span class="caps">IRC</span> as a resource for your PowerShell learning and for those sticky questions!</p>]]></content:encoded>
			<wfw:commentRss>http://huddledmasses.org/the-virtual-powershell-group/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
