<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://powershell.com/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>PowerShell for Windows</title><link>http://powershell.com/cs/forums/200.aspx</link><description>Moderated by PowerShell MVP &lt;a href="http://powershell.com/cs/content/experts.aspx#tobias-weltner"&gt;Dr. Tobias Weltner&lt;/a&gt;</description><dc:language>en</dc:language><generator>CommunityServer 2008.5 (Build: 30929.2835)</generator><item><title>Re: Trouble backgrounding .bat file invocations</title><link>http://powershell.com/cs/forums/thread/16123.aspx</link><pubDate>Mon, 23 Apr 2012 22:40:18 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:16123</guid><dc:creator>Tobias</dc:creator><slash:comments>0</slash:comments><comments>http://powershell.com/cs/forums/thread/16123.aspx</comments><wfw:commentRss>http://powershell.com/cs/forums/commentrss.aspx?SectionID=200&amp;PostID=16123</wfw:commentRss><description>&lt;p&gt;And regarding your question: whenever you hand over a script block to someone else (like Start-Job), variables will only survive if the script block runs in the same context. With Start-Job, you are initiating a completely new powershell.exe session with its own set of variables. So they are all empty.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Re: Trouble backgrounding .bat file invocations</title><link>http://powershell.com/cs/forums/thread/16122.aspx</link><pubDate>Mon, 23 Apr 2012 22:38:41 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:16122</guid><dc:creator>Tobias</dc:creator><slash:comments>0</slash:comments><comments>http://powershell.com/cs/forums/thread/16122.aspx</comments><wfw:commentRss>http://powershell.com/cs/forums/commentrss.aspx?SectionID=200&amp;PostID=16122</wfw:commentRss><description>&lt;p&gt;Do not use Start-Job.&lt;/p&gt;
&lt;p&gt;Do use Start-Process.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>Trouble backgrounding .bat file invocations</title><link>http://powershell.com/cs/forums/thread/15967.aspx</link><pubDate>Sat, 14 Apr 2012 03:40:18 GMT</pubDate><guid isPermaLink="false">f421715f-7aba-45f0-8a8d-44de5318a3a7:15967</guid><dc:creator>BillJr58</dc:creator><slash:comments>0</slash:comments><comments>http://powershell.com/cs/forums/thread/15967.aspx</comments><wfw:commentRss>http://powershell.com/cs/forums/commentrss.aspx?SectionID=200&amp;PostID=15967</wfw:commentRss><description>&lt;p&gt;&lt;strong&gt;Background:&lt;br /&gt;&lt;/strong&gt;I&amp;#39;m using PowerShell to automate a legacy build process.&amp;nbsp; There are a couple .bat files I need to invoke and would like to run them in parallel.&amp;nbsp; They end with a &amp;quot;Pause&amp;quot; command, so I need to supply input in order for the jobs to complete.&lt;/p&gt;
&lt;p&gt;I&amp;nbsp;can invoke the .bat files serially, simply using &lt;span style="text-decoration:underline;"&gt;&amp;quot; &amp;quot; |&lt;/span&gt; to satisfy the Pause command.&amp;nbsp; The trouble began when I tried to use Start-Job to run them in parallel.&amp;nbsp; Can you explain why PowerShell is not happy with this code?&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Code snippet:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; $jobs = @()&lt;br /&gt;&amp;nbsp;&amp;nbsp; foreach ( $jn in &amp;quot;compile_all_ada&amp;quot;, &amp;quot;compile_all_c&amp;quot; ) {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $bf = (Get-Location),&amp;quot;$jn.bat&amp;quot; -join &amp;quot;\&amp;quot;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; $jobs += Start-Job {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&amp;quot; &amp;quot; | &amp;amp; $bf) | Out-File -FilePath $jn.log -Encoding ascii -Force&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } -Name $jn&lt;br /&gt;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Invocation error:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&amp;gt;&amp;gt;&amp;gt; $jobs | Receive-Job&lt;br /&gt;The expression after &amp;#39;&amp;amp;&amp;#39; in a pipeline element produced an invalid object. It must result in a command name, script block &lt;br /&gt;or CommandInfo object.&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + CategoryInfo&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : InvalidOperation: (:) [], RuntimeException&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; + FullyQualifiedErrorId : BadExpression&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>