<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Asynchronous Processing using Powershell Jobs</title>
	<atom:link href="http://www.webofwood.com/2010/03/17/asynchronous-powershell-jobs/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.webofwood.com/2010/03/17/asynchronous-powershell-jobs/</link>
	<description>Wordpress weblog of John Wood, a Database Administrator</description>
	<lastBuildDate>Sat, 07 Jan 2012 21:20:41 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: slf</title>
		<link>http://www.webofwood.com/2010/03/17/asynchronous-powershell-jobs/comment-page-1/#comment-12900</link>
		<dc:creator>slf</dc:creator>
		<pubDate>Mon, 13 Dec 2010 19:16:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.webofwood.com/?p=116#comment-12900</guid>
		<description>Thanks for this, it got me heading in the correct direction.  In my case I wanted to use RoboCopy for the mirroring behavior (auto pruning of missing files in source, no-copy if the same, etc).  Below is my script, seems to be working great, using it push product bits out to all the different test VMs.

$source = &#039;c:\path\to\buildoutput&#039;

$targets = @(&#039;clientvm1&#039;, &#039;clientvm2&#039;, &#039;clientvm3&#039;, &#039;clientvm4&#039;, &#039;clientvm4&#039;, &#039;clientvm5&#039;, &#039;clientvm6&#039;)
$running_jobs = @()

foreach ($i in $targets) {
    $target = &#039;\\&#039; + $i + &#039;\c$\sp-profilegadget-latest&#039;
	$script_block_args = @($source,$target)
    $job = Start-Job -Scriptblock {
	    param ($source, $target)
	    robocopy $source $target /mir /mt /r:0 /w:0 /ns /nc /nfl /ndl /np /njh
	} -ArgumentList $script_block_args
	$running_jobs += $job
}

foreach ($j in $running_jobs) {
	Wait-Job $j
	Receive-Job $j
}</description>
		<content:encoded><![CDATA[<p>Thanks for this, it got me heading in the correct direction.  In my case I wanted to use RoboCopy for the mirroring behavior (auto pruning of missing files in source, no-copy if the same, etc).  Below is my script, seems to be working great, using it push product bits out to all the different test VMs.</p>
<p>$source = &#8216;c:\path\to\buildoutput&#8217;</p>
<p>$targets = @(&#8216;clientvm1&#8242;, &#8216;clientvm2&#8242;, &#8216;clientvm3&#8242;, &#8216;clientvm4&#8242;, &#8216;clientvm4&#8242;, &#8216;clientvm5&#8242;, &#8216;clientvm6&#8242;)<br />
$running_jobs = @()</p>
<p>foreach ($i in $targets) {<br />
    $target = &#8216;\\&#8217; + $i + &#8216;\c$\sp-profilegadget-latest&#8217;<br />
	$script_block_args = @($source,$target)<br />
    $job = Start-Job -Scriptblock {<br />
	    param ($source, $target)<br />
	    robocopy $source $target /mir /mt /r:0 /w:0 /ns /nc /nfl /ndl /np /njh<br />
	} -ArgumentList $script_block_args<br />
	$running_jobs += $job<br />
}</p>
<p>foreach ($j in $running_jobs) {<br />
	Wait-Job $j<br />
	Receive-Job $j<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

