<?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 &#187; Metadata</title>
	<atom:link href="http://huddledmasses.org/tag/metadata/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Fri, 27 Apr 2012 05:42:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<cloud domain='huddledmasses.org' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
		<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 [...]]]></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/' 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[Modules]]></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/' 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[Modules]]></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>
	</channel>
</rss>

