<?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>Green Folly<title>&#187; Powershell</title>
</title>
	<atom:link href="http://ericharrigan.com/blog/category/powershell/feed/" rel="self" type="application/rss+xml" />
	<link>http://ericharrigan.com/blog</link>
	<description></description>
	<lastBuildDate>Sun, 08 Aug 2010 04:34:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Poor man&#8217;s file compare with Powershell</title>
		<link>http://ericharrigan.com/blog/tech/poor-mans-file-compare-with-powershell/</link>
		<comments>http://ericharrigan.com/blog/tech/poor-mans-file-compare-with-powershell/#comments</comments>
		<pubDate>Mon, 23 Jun 2008 22:41:24 +0000</pubDate>
		<dc:creator>greenguy</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Tech]]></category>
		<category><![CDATA[file compare]]></category>
		<category><![CDATA[windiff]]></category>

		<guid isPermaLink="false">http://ericharrigan.com/blog/?p=44</guid>
		<description><![CDATA[Frustration levels went high today as I was burned by another bad config in our prod environment.  While we wait for a more robust config file management tool that will handle all our web app configs and service configs, we have relied on a Powershell script that stages code for prod and tweaks the config [...]]]></description>
			<content:encoded><![CDATA[<p>Frustration levels went high today as I was burned by another bad config in our prod environment.  While we wait for a more robust config file management tool that will handle all our web app configs and service configs, we have relied on a Powershell script that stages code for prod and tweaks the config files so that any environment specific changes for prod are made.  In the latest case, a bad config was checked into our repository and the Powershell script failed to catch the new pattern.  To get around running a diff tool against each file before each release (we have dozens of configs), I wrote the following script that serves as an indication as to what files are out of sync.  Operations can now run this script to understand what config changes are about to happen.</p>
<pre></pre>
<p><font color="#808080">function CompareFileContents([string]$filepath1, [string]$filepath2, [string] $logFile)<br />
{<br />
write-output &#8220;Comparing $filepath1 to $filepath2&#8243; | out-file $logFile -append<br />
Compare-Object -referenceObject $(Get-Content $filepath1) -differenceObject $(Get-Content $filepath2)  -syncWindow 0 | out-file $logFile -append<br />
}</font></p>
<p><font color="#808080">$date = Get-Date<br />
$configDiffLogFile = &#8220;D:\builds\ConfigFileCompare{0}{1:d2}{2:d2}-{3:d2}{4:d2}.txt&#8221; -f $date.year,$date.month,$date.day,$date.hour,$date.minute<br />
write-output &#8220;The config file diff output will be stored at $configDiffLogFile&#8221;</font></p>
<p><font color="#808080">CompareFileContents \\qapapp01\e$\SAJServices\ReleaseStage\PriorRelease\svc\SnagAJob\SAJ.EmployerSearch\SnagAJob.EmployerSearch.WinHost.exe.config \\qapapp01\e$\SAJServices\ReleaseStage\ReleaseToDeploy\svc\SnagAJob\SAJ.EmployerSearch\SnagAJob.EmployerSearch.WinHost.exe.config $configDiffLogFile</font></p>
<p>Couple of items on the script:</p>
<ol>
<li>The &#8220;-syncWindow 0&#8243;option ensures that each lines match sequentially. So if someone moves a line further down in the difference file, even though it has a match in the reference file, the change will be logged.</li>
<li>The filename format came from <a href="http://www.vistax64.com/powershell/62763-add-date-time-filename.html#post305384" target="_blank">this post</a> about a nifty way to use the -f format operator</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://ericharrigan.com/blog/tech/poor-mans-file-compare-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
