<?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; Manifest</title>
	<atom:link href="http://huddledmasses.org/tag/manifest/feed/" rel="self" type="application/rss+xml" />
	<link>http://huddledmasses.org</link>
	<description>You can do more than breathe for free...</description>
	<lastBuildDate>Sat, 28 Jan 2012 21:37:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</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>
	</channel>
</rss>

