<?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>youdidwhatwithtsql.com &#187; PowerShellPack</title>
	<atom:link href="http://www.youdidwhatwithtsql.com/tag/powershellpack/feed" rel="self" type="application/rss+xml" />
	<link>http://www.youdidwhatwithtsql.com</link>
	<description>making DBAs everywhere curse!</description>
	<lastBuildDate>Tue, 31 Jan 2012 12:21:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>PowershellPack STA Error</title>
		<link>http://www.youdidwhatwithtsql.com/powershellpack-sta-error/579</link>
		<comments>http://www.youdidwhatwithtsql.com/powershellpack-sta-error/579#comments</comments>
		<pubDate>Mon, 25 Jan 2010 20:51:29 +0000</pubDate>
		<dc:creator>Rhys</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Powershell STA mode]]></category>
		<category><![CDATA[Powershell Tools]]></category>
		<category><![CDATA[PowerShellPack]]></category>

		<guid isPermaLink="false">http://www.youdidwhatwithtsql.com/powershellpack-sta-error/579</guid>
		<description><![CDATA[I&#8217;m really into Powershell so I like trying out all the available tools. Somehow I&#8217;ve missed the release of the PowershellShellPack which has ten modules offering all kinds of additional functionality including file handling, operating system information, GUI and code generation. I followed the Channel 9 video and ran into a problem on the first [...]<p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/powershellpack-sta-error/579">PowershellPack STA Error</a></p>
]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m really into <a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx" target="_blank">Powershell</a> so I like trying out all the available tools. Somehow I&#8217;ve missed the release of the <a href="http://code.msdn.microsoft.com/PowerShellPack" target="_blank">PowershellShellPack</a> which has ten modules offering all kinds of additional functionality including file handling, operating system information, GUI and code generation. I followed the <a href="http://ecn.channel9.msdn.com/o9/ch9/3/6/0/8/8/4/Powershell4_ch9.wmv" target="_blank">Channel 9 video</a> and ran into a problem on the first example given.</p>
<p>First I ran the command <strong>Import-Module PowerShellPack</strong>.</p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/Powershell_Import_Module_PowerShellPack.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Powershell Import Module PowerShellPack" border="0" alt="Powershell Import Module PowerShellPack thumb PowershellPack STA Error" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/Powershell_Import_Module_PowerShellPack_thumb.png" width="644" height="375" /></a> </p>
<p>Then I tried to create, and display, a label as in the video example; <strong>New-Label &quot;Hello World&quot; -FontSize 40 -Show</strong></p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/powershell_sta_mode_error.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Powershell STA modeerror" border="0" alt="powershell sta mode error thumb PowershellPack STA Error" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/powershell_sta_mode_error_thumb.png" width="644" height="375" /></a> </p>
<p>This resulted in the following error.</p>
<pre>

New-Object : Exception calling &quot;.ctor&quot; with &quot;0&quot; argument(s): &quot;The calling thread must be STA, because many UI components require this.&quot;
At C:\Users\Rhys\Documents\WindowsPowerShell\Modules\WPK\GeneratedControls\PresentationFramework.ps1:30292 char:29
+         $Object = New-Object &lt;&lt;&lt;&lt;  System.Windows.Controls.Label
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodInvocationException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

</pre>
<p>OK, I seem to need to be running in STA mode. I Googled &quot;Powershell STA mode&quot; and discovered a <a href="http://stackoverflow.com/questions/1508704/does-powershell-sta-mode-eliminate-sharepoint-memory-leak-issue" target="_blank">Stackoverflow thread</a>. After reading this I thought I&#8217;d try starting Powershell with the switch <strong>-STA</strong>.</p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/powershell_start_in_sta_mode.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="powershell start in sta mode" border="0" alt="powershell start in sta mode thumb PowershellPack STA Error" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/powershell_start_in_sta_mode_thumb.png" width="644" height="375" /></a> </p>
<p>OK, that seemed to work. Now lets try to create that label again. First load the <a href="http://code.msdn.microsoft.com/PowerShellPack" target="_blank">PowerShellPack</a> modules again since we&#8217;ve started a new session.</p>
<p><strong>Import-Module PowerShellPack</strong></p>
<p><font color="#666666">Now try to create the label again.</font></p>
<p><strong>New-Label &quot;Hello World&quot; -FontSize 40 -Show</strong></p>
<p><a href="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/Powershell_Hello_World_Label.png"><img style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px" title="Powershell Hello World Label" border="0" alt="Powershell Hello World Label thumb PowershellPack STA Error" src="http://www.youdidwhatwithtsql.com/wp-content/uploads/2010/01/Powershell_Hello_World_Label_thumb.png" width="644" height="375" /></a></p>
<p>OK, that&#8217;s that hurdle over. Now I can get on with exploring what this tool can do for me.</p>
<p><map name='google_ad_map_579_a45beff5d2e172f6'>
<area shape='rect' href='http://imageads.googleadservices.com/pagead/imgclick/579?pos=0' coords='1,2,367,28' />
<area shape='rect' href='http://services.google.com/feedback/abg' coords='384,10,453,23'/></map>
<img usemap='#google_ad_map_579_a45beff5d2e172f6' border='0' src='http://imageads.googleadservices.com/pagead/ads?format=468x30_aff_img&amp;client=&amp;channel=&amp;output=png&amp;cuid=579&amp;url=http%3A%2F%2Fwww.youdidwhatwithtsql.com%2Fpowershellpack-sta-error%2F579' title="PowershellPack STA Error" alt=" PowershellPack STA Error" /></p><p>Post from: <a href="http://www.youdidwhatwithtsql.com">youdidwhatwithtsql.com</a><br/><br/><a href="http://www.youdidwhatwithtsql.com/powershellpack-sta-error/579">PowershellPack STA Error</a></p>
<div class="none"><div class="g-plusone" data-href="http://www.youdidwhatwithtsql.com/powershellpack-sta-error/579" size="standard" count="true"></div></div>]]></content:encoded>
			<wfw:commentRss>http://www.youdidwhatwithtsql.com/powershellpack-sta-error/579/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
<enclosure url="http://ecn.channel9.msdn.com/o9/ch9/3/6/0/8/8/4/Powershell4_ch9.wmv" length="57443159" type="video/x-ms-wmv" />
		</item>
	</channel>
</rss>

