<?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>The Geekery &#187; Jonathan Angliss</title>
	<atom:link href="http://jon.netdork.net/author/jon/feed" rel="self" type="application/rss+xml" />
	<link>http://jon.netdork.net</link>
	<description>The Usual Stuff...</description>
	<lastBuildDate>Sun, 18 Jul 2010 16:53:23 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Intro to SNMP</title>
		<link>http://jon.netdork.net/2010/07/18/intro-to-snmp?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=intro-to-snmp</link>
		<comments>http://jon.netdork.net/2010/07/18/intro-to-snmp#comments</comments>
		<pubDate>Sun, 18 Jul 2010 16:53:23 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Sys Admin]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/2010/07/18/intro-to-snmp</guid>
		<description><![CDATA[Matt Simmons, of Standalone Sysadmin fame, has a great post up about SNMP, giving a good all around introduction to SNMP.&#160; I highly recommend reading it if you’re getting started in networks, or even if you just want to brush up.]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F07%2F18%2Fintro-to-snmp">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F07%2F18%2Fintro-to-snmp&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly" height="61" width="50" />
			</a>
		</div><p>Matt Simmons, of <a title="Standalone Sysadmin" href="http://www.standalone-sysadmin.com/" target="_blank">Standalone Sysadmin</a> fame, has a great <a title="Standalone SA; Introduction to SNMP" href="http://www.standalone-sysadmin.com/blog/2010/07/introduction-to-snmp/" target="_blank">post</a> up about SNMP, giving a good all around introduction to SNMP.&#160; I highly recommend reading it if you’re getting started in networks, or even if you just want to brush up.</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/07/18/intro-to-snmp/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	<!-- google ad injected by adsense-optimizer http://www.adsenseoptimizer.de -->
			<div  style="padding:7px; display: block; margin-left: auto; margin-right: auto; text-align: center;"><!-- Linkblock number: 1 --><script type="text/javascript"><!--
	 
google_ad_client = "pub-5380792458095798";
google_ad_width = 468;
google_ad_height = 15;
google_ad_format = "468x15_0ads_al"; google_ad_channel ="";
google_color_border = "CCCCCC";
google_color_bg = "F7F7F7";
google_color_link = "2970A6";
//--></script>
<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>	<item>
		<title>PowerShell: Loops, ForEach, ForEach-Object, and control functions</title>
		<link>http://jon.netdork.net/2010/07/13/powershell-loops-foreach-control-functions?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-loops-foreach-control-functions</link>
		<comments>http://jon.netdork.net/2010/07/13/powershell-loops-foreach-control-functions#comments</comments>
		<pubDate>Wed, 14 Jul 2010 04:02:14 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=915</guid>
		<description><![CDATA[In my previous post about PowerShell and BITS, I stumbled on a weird quirk in the ForEach-Object function, which had me scratching my head for a bit. In most programming languages, where you have a for, loop, while, foreach, or other such loop, there is often a set of control functions that go with it. [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F07%2F13%2Fpowershell-loops-foreach-control-functions">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F07%2F13%2Fpowershell-loops-foreach-control-functions&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly" height="61" width="50" />
			</a>
		</div><p>In my previous post about <a href="http://jon.netdork.net/2010/07/08/powershell-and-bits" title="The Geekery; PowerShell and BITS">PowerShell and BITS</a>, I stumbled on a weird quirk in the ForEach-Object function, which had me scratching my head for a bit.</p>

<p><span id="more-915"></span></p>

<p>In most programming languages, where you have a for, loop, while, foreach, or other such loop, there is often a set of control functions that go with it.  <em>Continue</em> and <em>Break</em>.  These functions alter the way a loop is behaving at that time.  A call to <em>Continue</em> will stop the current loop iteration at that point in the code, and jump onto the next.  A simple example would look like this:</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #0000FF;">for</span><span style="color: #000000;">&#40;</span> <span style="color: #800080;">$i</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>; <span style="color: #800080;">$i</span> <span style="color: #FF0000;">-lt</span> <span style="color: #804000;">5</span>; <span style="color: #800080;">$i</span><span style="color: pink;">++</span> <span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$i</span> <span style="color: #FF0000;">-eq</span> <span style="color: #804000;">2</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #0000FF;">continue</span>;<br />
&nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; <span style="color: #800080;">$i</span><br />
<span style="color: #000000;">&#125;</span></div></div>

<p>This code simply takes the variable $i, sets it to 0, and whilst $i is less than 5, it loops through the code, each iteration increasing the value of $i by 1.  The if statement executes special code when $i gets to the number 2.  Now if we run this code, we get the following:</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #804000;">0</span><br />
<span style="color: #804000;">1</span><br />
<span style="color: #804000;">3</span><br />
<span style="color: #804000;">4</span></div></div>

<p>What happened was the counter hit 2, and the code said that it was done with this iteration, and continue processing the outer loop.  A <em>Break</em> on the other hand just tells the loop it&#8217;s done processing, and to stop looping, and get out.  Using the same example as above, but changing <em>Continue</em> to <em>Break</em> we get the output that looks like this:</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #804000;">0</span><br />
<span style="color: #804000;">1</span></div></div>

<p>This is because PowerShell has been told to stop processing any further.</p>

<p>Now for the quirk.  I discovered that <em>ForEach-Object</em> isn&#8217;t actually a programmatic keyword, it&#8217;s a cmdlet.  How does this affect the usage of the control functions?  Lets look at my code from my <a href="http://jon.netdork.net/2010/07/08/powershell-and-bits" title="The Geekery; PowerShell and BITS">BITS</a> article, and compare it to what I had.</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br /></div></td><td><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #800080;">$images</span> <span style="color: pink;">=</span> <a href="about:blank"><span style="color: #000080;">$_</span></a>.images<br />
<br />
&nbsp; &nbsp; <span style="color: #800080;">$job</span> <span style="color: pink;">=</span> <span style="color: #800080;">$null</span><br />
&nbsp; &nbsp; <span style="color: #800080;">$img_split</span> <span style="color: pink;">=</span> <span style="color: #800080;">$images</span>.Split<span style="color: #000000;">&#40;</span><span style="color: #800000;">'|'</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #0000FF;">for</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$i</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>; <span style="color: #800080;">$i</span> <span style="color: #FF0000;">-lt</span> <span style="color: #800080;">$img_split</span>.Count; <span style="color: #800080;">$i</span><span style="color: pink;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$img_split</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$i</span><span style="color: #000000;">&#93;</span>.Length <span style="color: #FF0000;">-eq</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">continue</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span></div></td></tr></tbody></table></div>

<p>As you can see, I&#8217;m using the continue function inside the array of strings for the images.  If the string value is empty, I skip onto the next one.  This is what the original code looked like:</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>5<br />6<br />7<br />8<br />9<br /></div></td><td><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #800080;">$images</span> <span style="color: pink;">=</span> <a href="about:blank"><span style="color: #000080;">$_</span></a>.images<br />
&nbsp; &nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$images</span>.Length <span style="color: #FF0000;">-eq</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">continue</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #800080;">$job</span> <span style="color: pink;">=</span> $null</div></td></tr></tbody></table></div>

<p>Whilst the code seems pretty similar, there is one distinct difference.  The first block of code is inside a loop, the second set is not.  Even though you think that <em>ForEach-Object</em> seems like a loop, it&#8217;s a cmdlet that does not behave the same way that a loop does.  How does this affect the behavior of the code?  Badly!  Because there is no loop, the control function looks for the next operation it can operate on.  It turns out that the next function it can operate on is the entire script.  It essentially <strong>kills</strong> the script right where the line is.  This means no processing of other objects in the &#8216;loop&#8217;, no continuing with the code further in the script, no nice handling of anything else in the script.  It&#8217;s done, finished, over.  My hint something wasn&#8217;t behaving right was the fact I should have had several thousand images, and yet I only had about 150.  It took 4 or 5 attempts, as well as various debug statements throughout the code to figure out why this was happening.  After I realized where it was going wrong, a Google search dropped me over to James Manning&#8217;s post <a href="http://blogs.msdn.com/b/jmanning/archive/2007/03/22/powershell-gotcha-foreach-keyword-vs-foreach-object-cmdlet.aspx" title="James Manning; PowerShell gotcha - foreach keyword vs. foreach-object cmdlet">PowerShell gotcha &#8211; foreach keyword vs. foreach-object cmdlet</a>.</p>

<p>So if you ever find yourself in need of an object loop, remember that <em>ForEach-Object</em> isn&#8217;t really a keyword, it&#8217;s a cmdlet, and does not behave the same.</p>

<p>See any mistakes? Want to add your feedback? Leave me a note in the comments, I love to hear from you.</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/07/13/powershell-loops-foreach-control-functions/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>PowerShell and BITS</title>
		<link>http://jon.netdork.net/2010/07/08/powershell-and-bits?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-and-bits</link>
		<comments>http://jon.netdork.net/2010/07/08/powershell-and-bits#comments</comments>
		<pubDate>Thu, 08 Jul 2010 20:25:23 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=906</guid>
		<description><![CDATA[Ever had to download a bunch of files from a website, and didn’t want to have to write an HTTP handler for it? This comes up on a regular basis here. We get requests from customers that have transferred from one vendor to another, and want to import all their photos to us. Here is [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F07%2F08%2Fpowershell-and-bits">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F07%2F08%2Fpowershell-and-bits&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly" height="61" width="50" />
			</a>
		</div><p>Ever had to download a bunch of files from a website, and didn’t want to have to write an <acronym title="HyperText Transfer Protocol">HTTP</acronym> handler for it? This comes up on a regular basis here. We get requests from customers that have transferred from one vendor to another, and want to import all their photos to us. Here is how I solve it.</p>

<p><span id="more-906"></span></p>

<h2>What is BITS?</h2>

<p><a href="http://msdn.microsoft.com/en-us/library/aa362708%28VS.85%29.aspx" title="Microsoft MSDN; About BITS">BITS</a>, or <em>Background Intelligent Transfer Service</em>, is a service bundled with Windows that is used to transfer files from websites. It was originally introduced in Windows XP RTM back in October 2001. You may not know it, but your computer uses it all the time if you have <em>Windows Automatic Updates</em> enabled.  It is an intelligent service that asynchronously transfers files, automatically adjusting bandwidth usage, throttling downloads, as bandwidth becomes available.  It can even be used to download files across computer starts.</p>

<h2>How is it useful in PowerShell?</h2>

<p>BITS is really easy to use, a few commands which I’ll show shortly, and you can download a bunch of files quickly, without having to write <acronym title="HyperText Transfer Protocol">HTTP</acronym> handler.  In my case above, I receive text files, with a list of image URLs, that need to be imported.</p>

<p>Here is how to do a very simple, single file, transfer.</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Import<span style="color: pink;">-</span>Module BitsTransfer<br />
<span style="color: #800080;">$job</span> <span style="color: pink;">=</span> Start<span style="color: pink;">-</span>BitsTransfer <span style="color: pink;">-</span>Source http:<span style="color: pink;">//</span>somedomain.com<span style="color: pink;">/</span>somefile.jpg <span style="color: #008080; font-style: italic;">-Destination</span> c:\images\somefile.jpg <span style="color: pink;">-</span>Asynchronous<br />
<span style="color: #0000FF;">while</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$job</span>.JobState.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">'Transferring'</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-or</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$job</span>.JobState.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">'Connecting'</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span><br />
<span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #008080; font-weight: bold;">Sleep</span> <span style="color: #804000;">3</span><br />
<span style="color: #000000;">&#125;</span><br />
Complete<span style="color: pink;">-</span>BitsTransfer <span style="color: pink;">-</span>BitsJob $job</div></div>

<p>Relatively simple, a few lines of code for a single file.  However, BITS really shines when you’re working with multiple files to download.</p>

<p>As the files I receive are quite often comma-separated values (CSV) files, we can use the rather handy <a href="http://technet.microsoft.com/en-us/library/dd347665.aspx" title="Microsoft TechNet; Import-CSV">Import-CSV</a> function, and we build up from there.</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;height:300px;"><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Import<span style="color: pink;">-</span>Module BitsTransfer<br />
<span style="color: #800080;">$filedata</span> <span style="color: pink;">=</span> <span style="color: #008080; font-weight: bold;">Import-CSV</span> c:\images\import.csv<br />
<span style="color: #800080;">$filedata</span> <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">ForEach-Object</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; <span style="color: #800080;">$vin</span> <span style="color: pink;">=</span> <a href="about:blank"><span style="color: #000080;">$_</span></a>.VIN<br />
&nbsp; &nbsp; <span style="color: #800080;">$images</span> <span style="color: pink;">=</span> <a href="about:blank"><span style="color: #000080;">$_</span></a>.Images<br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #800080;">$job</span> <span style="color: pink;">=</span> <span style="color: #800080;">$null</span><br />
&nbsp; &nbsp; <br />
&nbsp; &nbsp; <span style="color: #800000;">&quot;Processing VIN: {0}&quot;</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$vin</span><br />
&nbsp; &nbsp; <span style="color: #800080;">$img_split</span> <span style="color: pink;">=</span> <span style="color: #800080;">$images</span>.Split<span style="color: #000000;">&#40;</span><span style="color: #800000;">'|'</span><span style="color: #000000;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #0000FF;">for</span><span style="color: #000000;">&#40;</span><span style="color: #800080;">$i</span> <span style="color: pink;">=</span> <span style="color: #804000;">0</span>; <span style="color: #800080;">$i</span> <span style="color: #FF0000;">-lt</span> <span style="color: #800080;">$img_split</span>.Count; <span style="color: #800080;">$i</span><span style="color: pink;">++</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$img_split</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$i</span><span style="color: #000000;">&#93;</span>.Length <span style="color: #FF0000;">-eq</span> <span style="color: #804000;">0</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">continue</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$outpath</span> <span style="color: pink;">=</span> <span style="color: #800000;">'C:\Images\{0}_{1}.jpg'</span> <span style="color: #FF0000;">-f</span> <span style="color: #800080;">$vin</span><span style="color: pink;">,</span> <span style="color: #800080;">$i</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$job</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #800080;">$job</span> <span style="color: pink;">=</span> Start<span style="color: pink;">-</span>BitsTransfer <span style="color: pink;">-</span>Source <span style="color: #800080;">$img_split</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$i</span><span style="color: #000000;">&#93;</span> <span style="color: #008080; font-style: italic;">-Destination</span> <span style="color: #800080;">$outpath</span> <span style="color: pink;">-</span>Asynchronous<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> <span style="color: #0000FF;">else</span> <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Add<span style="color: pink;">-</span>BitsFile <span style="color: pink;">-</span>BitsJob <span style="color: #800080;">$job</span> <span style="color: pink;">-</span>Source <span style="color: #800080;">$img_split</span><span style="color: #000000;">&#91;</span><span style="color: #800080;">$i</span><span style="color: #000000;">&#93;</span> <span style="color: #008080; font-style: italic;">-Destination</span> <span style="color: #800080;">$outpath</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
&nbsp; &nbsp; <span style="color: #0000FF;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$job</span> <span style="color: #FF0000;">-ne</span> <span style="color: #800080;">$null</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> &nbsp; &nbsp;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #0000FF;">while</span><span style="color: #000000;">&#40;</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$job</span>.JobState.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">'Transferring'</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-or</span> <span style="color: #000000;">&#40;</span><span style="color: #800080;">$job</span>.JobState.ToString<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF0000;">-eq</span> <span style="color: #800000;">'Connecting'</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#41;</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #008080; font-weight: bold;">Sleep</span> <span style="color: #804000;">3</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000000;">&#125;</span> &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; Complete<span style="color: pink;">-</span>BitsTransfer <span style="color: pink;">-</span>BitsJob <span style="color: #800080;">$job</span><br />
&nbsp; &nbsp; <span style="color: #000000;">&#125;</span><br />
<span style="color: #000000;">&#125;</span></div></div>

<p>This is a little more complicated, but is still pretty simple.  It introduces <em>Add-BitsFile</em> which allows you to add files to an existing job, and a simple <em>ForEach</em> loop to go through an array of URLs.</p>

<p>I&#8217;ve made a few assumptions here, and thrown out all kinds of error handling in favor of a quick code turn around.  For example, the job state of a BITS job can be one of nine options (which you can see <a href="http://msdn.microsoft.com/en-us/library/aa362809(v=VS.85).aspx" title="Microsoft MSDN; BITS Job State">here</a>), but I assume only two.  I&#8217;m also not handling cases where I exceed the number of jobs, but that never happens because I only ever have one job running at a time.  I&#8217;ll probably work on tidying it up a little for other people&#8217;s use, but for now, it&#8217;s just me using it where I work, so the impact of an error is very minimal.</p>

<p>Give it a shot, download some images off of Flickr, or go a little further, and test it against downloads from Microsoft.</p>

<p>Got any questions? Hints? Tips? Leave them in the comments, I&#8217;d love to hear from you.</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/07/08/powershell-and-bits/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Windows 2008, and Hibernation</title>
		<link>http://jon.netdork.net/2010/07/06/windows-2008-and-hibernation?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=windows-2008-and-hibernation</link>
		<comments>http://jon.netdork.net/2010/07/06/windows-2008-and-hibernation#comments</comments>
		<pubDate>Wed, 07 Jul 2010 01:51:18 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[Work]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=903</guid>
		<description><![CDATA[Whilst driving back from our 4th of July celebrations in San Antonio, I got alerted to a server running low on disk space.&#160; As it hadn’t hit critical, and there was still a fair bit of space left, I decided to wait until I got home.&#160; When I looked at the server, I pulled up [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F07%2F06%2Fwindows-2008-and-hibernation">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F07%2F06%2Fwindows-2008-and-hibernation&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly" height="61" width="50" />
			</a>
		</div><p></p><p>Whilst driving back from our 4th of July celebrations in San Antonio, I got alerted to a server running low on disk space.&#160; As it hadn’t hit critical, and there was still a fair bit of space left, I decided to wait until I got home.&#160; When I looked at the server, I pulled up my trusted space analyzer, <a href="http://www.jam-software.com/treesize_free/" target="_blank">TreeSize</a>.</p>  <span id="more-903"></span>  <p><a href="http://jon.netdork.net/wp-content/uploads/2010/07/image.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" class="wlDisabledImage" title="image" border="0" alt="image" align="right" src="http://jon.netdork.net/wp-content/uploads/2010/07/image_thumb.png" width="244" height="72" /></a>A quick analysis of the drive, and a report showed that there was a hefty chunk of space lost to the WinSXS directory, and 8GB of <em>Files</em> in the root of C:.&#160; This was a little odd, I know I usually use c:\temp from time to time, but never the root.&#160; To find out what was there, I first had to show hidden and system files.&#160; To do this, go to Tools, then Folder Options, then onto the View tab.&#160; There are 3 options there that we need to change.</p>  <ol>   <li>Change “Hidden files and folders” to “Show hidden files and folders”</li>    <li>Uncheck “Hide extensions for known file types”</li>    <li>Uncheck “Hide protected operating system files (Recommended)”</li> </ol>  <p>I <strong><em>highly</em></strong> recommend doing 2 all the time, you never know when somebody might sent a .txt.exe file.&#160; Changing 3 will prompt that it isn’t recommended, but do it anyway, the files I was having issues with were still hidden after changing the first two.</p>  <p>After making these changes, two files appeared that were the culprits to the lost disk space.&#160; <em>Pagefile.sys</em> and <em>Hiberfil.sys</em>.&#160; I’ll leave the explanation of the <em><a title="TechNet; What is the Page File for Anyway?" href="http://blogs.technet.com/b/askperf/archive/2007/12/14/what-is-the-page-file-for-anyway.aspx" target="_blank">Pagefile</a></em> to the experts.&#160; <em>Hiberfil.sys</em> is a file that is used to handle the state of memory, and running applications when you hibernate your computer.&#160; </p>  <h2>What is hibernation?</h2>  <p>Hibernation is a heavy sleep state for computers where all the running processes are frozen, the memory is locked, and all the states are saved into that file, then the computer is powered down.&#160; When the computer is turned back on, the operating system sees this <em>state</em> file, and starts to reload everything from there.&#160; This makes it appear like the computer was never even turned off.&#160; The applications are resumed, everything is back to the state it was before hibernation was kicked off.</p>  <h2>Why is that bad?</h2>  <p>Generally speaking, it isn’t.&#160; In fact, it’s a great thing for home computers.&#160; When you’re done reading your email at night, if you hibernate your computer, and hop into bed, your computer will be off, saving power.&#160; However this isn’t so good for servers.&#160; In 95% of cases, servers don’t ever need to hibernate.&#160; They usually have tasks, and operations that they need to run all the time, which means putting them in a state of hibernation is a bad thing as the tasks won’t be run.</p>  <h2>How do you stop this?</h2>  <p>Usually, servers have this feature turned off, but for some reason this particular one had it enabled.&#160; I’ve done some looking around, and it seems it’s may have actually been a default option to have it enabled, but for some (<em>lucky</em>) reason a handful of our other servers don’t have it on.&#160; In earlier versions of Windows, disabling the hibernation option was a case of removing a check mark from a box.&#160; This was done in the <em>Control Panel</em> under <em>Power Options</em>, and the <em>Hibernate</em> tab.&#160; However, in Windows 2008 this option was removed, and you now have to use a command line to manage this advanced option.</p>  <p></p>

<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp;powercfg –hibernate off</div></div>

<p></p>  <p>Within about 10 seconds of issuing that command, the <em>Hiberfil.sys </em>file disappeared, and I recovered 4GB of disk space.&#160; You can read more about the <em>powercfg</em> command <a title="TechNet; Powercfg Command-Line options" href="http://technet.microsoft.com/en-us/library/cc748940%28WS.10%29.aspx" target="_blank">here</a>.</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/07/06/windows-2008-and-hibernation/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Configuration Management (Part II): Setting up SVN</title>
		<link>http://jon.netdork.net/2010/06/28/configuration-management-part-ii-setting-up-svn?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=configuration-management-part-ii-setting-up-svn</link>
		<comments>http://jon.netdork.net/2010/06/28/configuration-management-part-ii-setting-up-svn#comments</comments>
		<pubDate>Tue, 29 Jun 2010 01:12:17 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Sys Admin]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=885</guid>
		<description><![CDATA[In part II of my walk through on configuration management, I&#8217;m going to work on setting up Subversion (SVN). SVN is a version control system and, just like any version control system, is used to keep track of changes. The most common use is in a development environment with teams of developers so that everybody [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F28%2Fconfiguration-management-part-ii-setting-up-svn">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F28%2Fconfiguration-management-part-ii-setting-up-svn&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly" height="61" width="50" />
			</a>
		</div><p>In part II of my walk through on configuration management, I&#8217;m going to work on setting up <a href="http://subversion.apache.org/" title="Apache Subversion">Subversion</a> (<acronym title="Subversion">SVN</acronym>).  <acronym title="Subversion">SVN</acronym> is a version control system and, just like any version control system, is used to keep track of changes.  The most common use is in a development environment with teams of developers so that everybody can work on the code, without having to worry about other people&#8217;s work.  It&#8217;s obviously not limited there, it can be used as a form of backup, keeping a track of what you&#8217;ve changed, and when.  This is how we&#8217;ll be using it for our configuration management.</p>

<p><span id="more-885"></span></p>

<h2>Installing <acronym title="Subversion">SVN</acronym></h2>

<p>I&#8217;m going to make the assumption you know how to install Linux.  If not, there are plenty of guides on doing so around the internet, and most come with a pretty easy to use installer.  With that said, I am starting this off with a completely blank slate.  I installed <a href="http://www.debian.org" title="Debian">Debian</a> 5.0.4 inside a <a href="http://www.virtualbox.org" title="Oracle VirtualBox">VirtualBox</a> instance.  I&#8217;ll be installing <acronym title="Subversion">SVN</acronym> on the same server for now, but it could be installed anywhere that supports it.</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> subversion</div></div>

<p>The above command needs to be run as <em>root</em>.  You can do the same as a normal user as long as you prefix the command with <em>sudo</em>.</p>

<h2>Creating the repository</h2>

<p>Next step is to create the repository we&#8217;ll be working with for the configurations.</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>srv<span style="color: #000000; font-weight: bold;">/</span><span style="color: #c20cb9; font-weight: bold;">svn</span><br />
<span style="color: #c20cb9; font-weight: bold;">svnadmin</span> create <span style="color: #660033;">--fs-type</span> fsfs <span style="color: #000000; font-weight: bold;">/</span>srv<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>thebe_config</div></div>

<p>You can name the repository whatever you want, I used thebe_config, <a href="http://www.solarviews.com/eng/thebe.htm" title="Jupiter's Moon; Thebe">Thebe</a> is the name of the server, and the second part is obvious.  Next we&#8217;ll create a group for those that will be working on the <acronym title="Subversion">SVN</acronym> project, and add the users.  As it&#8217;s only me, that&#8217;s easy&#8230;</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">groupadd subversion<br />
addgroup jonathan subversion</div></div>

<p>That&#8217;s the basic setup done&#8230; Now onto more fun stuff.</p>

<h2>Using the repository</h2>

<p>Generally speaking, <acronym title="Subversion">SVN</acronym> requires you to import a project, and checkout in another location.  For example, a basic initial import, and check out would look something like this:</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> my_test<br />
<span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;First import test&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span> my_test<span style="color: #000000; font-weight: bold;">/</span>test_file.txt<br />
<span style="color: #c20cb9; font-weight: bold;">svn</span> import <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;This is the initial setup&quot;</span> my_test<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>srv<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>thebe_config<span style="color: #000000; font-weight: bold;">/</span>trunk<br />
<span style="color: #c20cb9; font-weight: bold;">svn</span> checkout <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>srv<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>thebe_config<span style="color: #000000; font-weight: bold;">/</span>trunk newproject</div></div>

<p>If you tried to checkout the project on-top of the existing code you already put up, you&#8217;d get an error like this:</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">svn</span> checkout <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>srv<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>thebe_config<span style="color: #000000; font-weight: bold;">/</span>trunk my_test<br />
snv: Failed to add <span style="color: #c20cb9; font-weight: bold;">file</span> <span style="color: #ff0000;">'my_test/test_file.txt'</span>: an unversioned <span style="color: #c20cb9; font-weight: bold;">file</span> of the same name already exists</div></div>

<p>This isn&#8217;t so good for us, because we can hardly delete /etc.  That being said, <acronym title="Subversion">SVN</acronym> has it covered, with what they document as an &#8220;<a href="http://subversion.apache.org/faq.html#in-place-import" title="SVN FAQ; In-Place import">in-place &#8216;import&#8217;</a>&#8220;.  The really cool thing about this, they document exactly what we&#8217;re trying to do, version-control the /etc structure.  So instead of importing /etc, we fake it.</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">svn</span> <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #660033;">--parents</span> <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>srv<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>thebe_config<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>etc<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<br />
<span style="color: #c20cb9; font-weight: bold;">svn</span> checkout <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>srv<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>thebe_config<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>etc .<br />
<span style="color: #c20cb9; font-weight: bold;">svn</span> add <span style="color: #000000; font-weight: bold;">*</span><br />
<span style="color: #c20cb9; font-weight: bold;">svn</span> commit <span style="color: #660033;">-m</span> <span style="color: #ff0000;">&quot;Initial check-in of /etc&quot;</span></div></div>

<p>Whilst it&#8217;s not documented in the <acronym title="Frequently Asked Questions">FAQ</acronym> there, the <em>&#8211;parents</em> option is similar to that of the normal <em>mkdir</em>, it recursively creates the directory structure down to the child we&#8217;re making.  In this case, trunk/etc.  After the last 2 commands, you should see a stream of data zip by you.  In the above example, I added the entire content of /etc, you can restrict it to certain directories if you want, say apache2, or samba, or you can go the whole way, and do the above.</p>

<p>Now it&#8217;s all checked in, lets see what it looks like:</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">svnlook</span> <span style="color: #c20cb9; font-weight: bold;">tree</span> <span style="color: #000000; font-weight: bold;">/</span>srv<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>thebe_config <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">more</span></div></div>

<p>After that, you should see a nice structured view of your checked in directory structure.  </p>

<h2>A gotcha with <acronym title="Subversion">SVN</acronym></h2>

<p>Before we go messing with these files, and testing everything is working well, we need to note something about <acronym title="Subversion">SVN</acronym>, that is important to the /etc directory structure.  File permissions.  <acronym title="Subversion">SVN</acronym> does <strong>not</strong> record file permissions.  This is an issue for some parts of the /etc directory, such as the shadow file, or the group file, or that htpasswd file you created to restrict users access.</p>

<p><acronym title="Subversion">SVN</acronym> allows you to store properties information along side each file, this file can contain all kinds of information, such as copyright data, license information, and all that fun stuff.  A crafty contributor too advantage of that, and created a script called <a href="http://svn.apache.org/repos/asf/subversion/trunk/contrib/client-side/asvn" title="SVN Contrib; ASVN">asvn</a>.  This script is a wrapper around the usual <em>svn</em> command, and executes some work either before a commit, or after a checkout.  So we need to grab a copy of this script:</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">wget</span> http:<span style="color: #000000; font-weight: bold;">//</span>svn.apache.org<span style="color: #000000; font-weight: bold;">/</span>repos<span style="color: #000000; font-weight: bold;">/</span>asf<span style="color: #000000; font-weight: bold;">/</span>subversion<span style="color: #000000; font-weight: bold;">/</span>trunk<span style="color: #000000; font-weight: bold;">/</span>contrib<span style="color: #000000; font-weight: bold;">/</span>client-side<span style="color: #000000; font-weight: bold;">/</span>asvn <span style="color: #660033;">-O</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>asvn<br />
<span style="color: #c20cb9; font-weight: bold;">chmod</span> a+rx <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>asvn<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>etc<br />
asvn commit</div></div>

<p>After the last command, you&#8217;ll see a bunch of stuff zoom past, and you will be prompted for a commit message, I did &#8220;permissions fixup&#8221;, and hit CTRL X and yes.  More stuff zooms by, and you should see a message appear that tells you the revision number has incremented.  Now to see if it worked&#8230;</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">svn</span> proplist <span style="color: #660033;">--verbose</span> group<br />
Properties on <span style="color: #ff0000;">'group'</span>:<br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">file</span>:permissions &nbsp;: <span style="color: #007800;">mode</span>=<span style="color: #000000;">644</span> <span style="color: #007800;">user</span>=root<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">group</span>=root<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>

<p>Excellent, now the last test, see what the checkout looks like, and see if it matches&#8230;</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>thebe_config<br />
<span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<br />
asvn checkout <span style="color: #c20cb9; font-weight: bold;">file</span>:<span style="color: #000000; font-weight: bold;">///</span>srv<span style="color: #000000; font-weight: bold;">/</span>svn<span style="color: #000000; font-weight: bold;">/</span>thebe_config<span style="color: #000000; font-weight: bold;">/</span>trunk <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>thebe_config</div></div>

<p>More scrolling of lots of boring text, but you should notice stuff like &#8220;checking {somefile} for symlinks&#8221;.  This is the asvn script doing it&#8217;s work, and rebuilding permissions and symlinks.  In my example, I&#8217;d checked in everything, which includes the precious &#8220;shadow&#8221; file (I&#8217;d not recommend adding that one, add it to the svn:ignore list).  I did so to provide a sample file with differing permissions.  The original file is locked down to specific user and group:</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>shadow<br />
<span style="color: #660033;">-rw-r-----</span> <span style="color: #000000;">1</span> root shadow <span style="color: #000000;">738</span> <span style="color: #000000;">2010</span>-06-<span style="color: #000000;">27</span> <span style="color: #000000;">19</span>:<span style="color: #000000;">42</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>shadow<br />
$ <span style="color: #c20cb9; font-weight: bold;">svn</span> proplist <span style="color: #660033;">--verbose</span> <span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span>shadow<br />
Properties on <span style="color: #ff0000;">'/etc/shadow'</span>:<br />
&nbsp; <span style="color: #c20cb9; font-weight: bold;">file</span>:permissions : <span style="color: #007800;">mode</span>=<span style="color: #000000;">640</span> <span style="color: #007800;">user</span>=root<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">0</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #007800;">group</span>=shadow<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000;">42</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></div></div>

<p>Lines starting with the $ are the commands I executed.  The rest is the response from the server.  As you can see, the permissions match..  Now the results in our test checkout&#8230;</p>

<div class="codecolorer-container bash default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">$ <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>tmp<span style="color: #000000; font-weight: bold;">/</span>thebe_config<span style="color: #000000; font-weight: bold;">/</span>etc<span style="color: #000000; font-weight: bold;">/</span><br />
$ <span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-l</span> shadow<br />
<span style="color: #660033;">-rw-r-----</span> <span style="color: #000000;">1</span> root shadow <span style="color: #000000;">738</span> <span style="color: #000000;">2010</span>-06-<span style="color: #000000;">27</span> <span style="color: #000000;">20</span>:06 shadow</div></div>

<p>Permissions match, size matches, so it looks like <acronym title="Subversion">SVN</acronym> now has a good copy of the file properties, and the version I have checked in is the same as the one I have in /etc.  As a side note, it should be worth remembering that some of the permissions cannot be set by anybody but root, so a lot of this work will probably require root, or sudo access.  That being said, you&#8217;re editing /etc, so you should already be doing that.</p>

<h2>Wrap-up</h2>

<p>So far, we&#8217;ve covered why we want to use a version control repository for our configurations.  We&#8217;ve also setup <acronym title="Subversion">SVN</acronym>, and got the basics going, including extended <acronym title="Subversion">SVN</acronym> to include extra data to handle file properties.  Next up is the basics of using <acronym title="Subversion">SVN</acronym>, and how it&#8217;ll be helping us out here in /etc and configuration land.</p>

<p>If you see any errors, or have any suggestions, feel free to leave them in the comments.  Want me to write about something else? Drop me an idea, and I&#8217;ll see what I can do.</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/06/28/configuration-management-part-ii-setting-up-svn/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Configuration Management (Part I): Introduction</title>
		<link>http://jon.netdork.net/2010/06/20/configuration-management-part-i-introduction?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=configuration-management-part-i-introduction</link>
		<comments>http://jon.netdork.net/2010/06/20/configuration-management-part-i-introduction#comments</comments>
		<pubDate>Mon, 21 Jun 2010 01:22:19 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Sys Admin]]></category>
		<category><![CDATA[Technology]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=876</guid>
		<description><![CDATA[I&#8217;ve been asked to write a post on configuration management, and version control by a friend, Steven Klassen. Instead of a single post, I&#8217;m going to break this into several posts as some parts might be unimportant to some, and they can easily skip a whole post. I&#8217;ll be posting this over a few days, [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F20%2Fconfiguration-management-part-i-introduction">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F20%2Fconfiguration-management-part-i-introduction&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly" height="61" width="50" />
			</a>
		</div><p>I&#8217;ve been asked to write a post on configuration management, and version control by a friend, <a href="http://www.stevenklassen.com/" title="Steven Klassen">Steven Klassen</a>.  Instead of a single post, I&#8217;m going to break this into several posts as some parts might be unimportant to some, and they can easily skip a whole post.  I&#8217;ll be posting this over a few days, so stay tuned.  If you&#8217;re not subscribed to my <a href="http://feeds.feedburner.com/TheGeekery" title="The Geekery; RSS Feed"><acronym title="Really Simple Syndication">RSS</acronym> feed</a>, now would be a great time.</p>

<p><span id="more-876"></span></p>

<h2>The Request</h2>

<p>Earlier today, Steven asked if I used any form of version control.  It was a leading question, straight into &#8220;dev only or system files&#8221;?  His questions were targeted, he was searching for guidance.  Another question or two later, and it boils down to this:</p>

<ul>
<li>Do you use version control for system files?</li>
<li>Files like domain zone files?</li>
<li>What about multi-user environments?</li>
<li>Can you write it up?</li>
</ul>

<p>My take away on the questions boils down to two things; configuration management, and backups.  Anybody that has managed any type of system has, at some point, messed up the configuration file, and forgotten what they did to get there in the first place.  Those who have been at it a while will usually do a quick copy before they do any modifications.  But, as Steven found out in the past, best laid plans can be foiled by a <a href="http://www.stevenklassen.com/2010/06/16/murphy/" title="Steven Klassen; Murphy">simple typo</a>. </p>

<h2>Version Control</h2>

<p>This is what version control is all about.  It acts as a backup, whilst keeping a running history of what you did between changes.  Version control, or revision control as it&#8217;s also known, is big business.  Anywhere you find a big name development company, you&#8217;ll find they&#8217;ve probably developed a revision control system to go with whatever they&#8217;re offering.  Take a look at <a href="http://en.wikipedia.org/wiki/Comparison_of_revision_control_software" title="Wikipedia; Comparison of revision control software">this</a> Wikipedia entry comparing just a handful of them.</p>

<h2>Configuration Management and Version Control</h2>

<p>You don&#8217;t have to be a genius to figure out how useful version control can be for configuration management, but in case your brain often goes off to lala land like <a href="http://twitter.com/j_angliss/status/16407172868" title="Twitter; j_angliss">mine</a>, here is a run down on a few reasons you should really consider using it&#8230;</p>

<ul>
<li>What did I just change again? And why is that service not starting any more? Oh hell&#8230;</li>
<li>6 months down the road, can you figure out <em>why</em> you changed that line to Apache to start 10 daemons instead of 5? No? Most version control systems allow you to add comments to your commits.</li>
<li>As above, but why did Fred in your team change that entry back down to 7 a week later?</li>
<li>In the words of Homer&#8230; <strong>Doh!!</strong> I wasn&#8217;t supposed to delete/overwrite that file!</li>
</ul>

<p>So, there are 4 obvious cases as to why you&#8217;d want to use version control.</p>

<h2>The Breakdown</h2>

<p>As I said at the beginning, I&#8217;ll be breaking this down into several parts.  I expect them to be something along these lines:</p>

<ul>
<li>Introduction</li>
<li>Setting up <acronym title="Subversion">SVN</acronym> and the base repository</li>
<li>Using your repository</li>
<li>Educating your team members</li>
<li>Maintenance and monitoring</li>
<li>Conclusion, and follow-up ideas.</li>
</ul>

<p>If you&#8217;re interested, keep an eye open for the rest of the series.  If not, send me something you&#8217;d like to see me write about.  I&#8217;m open to suggestions, and will probably butcher anything you can throw at me.</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/06/20/configuration-management-part-i-introduction/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	<!-- google ad injected by adsense-optimizer http://www.adsenseoptimizer.de -->
			<div  style="padding:7px; display: block; margin-left: auto; margin-right: auto; text-align: center;"><!-- Ad number: 1 --><script type="text/javascript"><!--
    	 
    	google_ad_client = "pub-5380792458095798"; google_alternate_color = "FFFFFF";
		google_ad_width = 468; google_ad_height = 60;
		google_ad_format = "468x60_as"; google_ad_type = "text";
		google_ad_channel =""; google_color_border = "CCCCCC";
		google_color_link = "2970A6"; google_color_bg = "F7F7F7";
		google_color_text = "555555"; google_color_url = "2970A6";
		google_ui_features = "rc:10"; //--></script>
		<script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script></div>	<item>
		<title>Massive Uptimes, or the failure of them&#8230;</title>
		<link>http://jon.netdork.net/2010/06/18/massive-uptimes-or-the-failure-of-them?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=massive-uptimes-or-the-failure-of-them</link>
		<comments>http://jon.netdork.net/2010/06/18/massive-uptimes-or-the-failure-of-them#comments</comments>
		<pubDate>Sat, 19 Jun 2010 04:39:26 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Networking]]></category>
		<category><![CDATA[SysAdmin]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=872</guid>
		<description><![CDATA[The Nubby Admin has a great post on uptimes, and the old fascination of having a large uptime. Okay, you can get your minds out the gutter now, not that kind of up time. We&#8217;re talking servers here. The post covers a hidden fear, and the goods and bads of large server uptimes. A good [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F18%2Fmassive-uptimes-or-the-failure-of-them">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F18%2Fmassive-uptimes-or-the-failure-of-them&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly&amp;hashtags=SysAdmin" height="61" width="50" />
			</a>
		</div><p><a href="http://thenubbyadmin.com/" title="The Nubby Admin">The Nubby Admin</a> has a <strong>great</strong> <a href="http://thenubbyadmin.com/2010/06/16/epic-uptime-bragging-rights-or-epic-fail/?utm_source=TheGeekery&amp;utm_medium=web&amp;utm_campaign=epic-uptime-bragging-rights-or-epic-fail" title="The Nubby Admin; Epic Uptime – Bragging Rights or Epic Fail?">post</a> on uptimes, and the old fascination of having a large uptime.  Okay, you can get your minds out the gutter now, not that kind of <em>up</em> time.  We&#8217;re talking servers here.  </p>

<p>The post covers a hidden fear, and the goods and bads of large server uptimes.  A good read, and one you should look at if you&#8217;re watching your server rolling over into the third year of being running.  I get a mention (well more of a quote), and seem to fall in with the general crowd, large server uptimes are generally bad.</p>

<p>Go read, enjoy, learn something new from the great minds Wesley is surrounding himself with (myself excluded).</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/06/18/massive-uptimes-or-the-failure-of-them/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IIS and unknown file types</title>
		<link>http://jon.netdork.net/2010/06/17/iis-and-unknown-file-types?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=iis-and-unknown-file-types</link>
		<comments>http://jon.netdork.net/2010/06/17/iis-and-unknown-file-types#comments</comments>
		<pubDate>Thu, 17 Jun 2010 20:01:34 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[Work]]></category>
		<category><![CDATA[IIS]]></category>
		<category><![CDATA[SysAdmin]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=867</guid>
		<description><![CDATA[Since IIS6, or there abouts, IIS will not host a file that it does not understand, or doesn&#8217;t have a MIME handler for. This is a security feature, but can cause some unknown issues&#8230; We use some customer facing training software by Skillsoft. They produce a Java application which allows you to record voice, and [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F17%2Fiis-and-unknown-file-types">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F17%2Fiis-and-unknown-file-types&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly&amp;hashtags=IIS,SysAdmin" height="61" width="50" />
			</a>
		</div><p>Since IIS6, or there abouts, <acronym title="Internet Information Services">IIS</acronym> will not host a file that it does not understand, or doesn&#8217;t have a <acronym title="Multipurpose Internet Mail Extension">MIME</acronym> handler for.  This is a security feature, but can cause some unknown issues&#8230;</p>

<p><span id="more-867"></span></p>

<p>We use some customer facing training software by Skillsoft.  They produce a Java application which allows you to record voice, and screen shows for training, and follow up with a questionnaire after.  Unfortunately because it&#8217;s Java, when something goes wrong, it&#8217;s very <em>blackbox</em>((A term coined to explain that you can see the outsides, but have no idea what&#8217;s going on inside)) like, making it hard to diagnose any issues.  In this case, the splash screen would load, and that&#8217;s where it&#8217;d stop.</p>

<p>Fortunately, the Java console does provide enough information to give us a hint as to what might be wrong.  When opening a Java application, the little console app appears in the notification area next to the clock.  This allows you to see if the app throws any errors.  In our case, it was complaining that a file with the extension .properties was missing from the server (<acronym title="Internet Information Services">IIS</acronym> was throwing a 404 message).  A quick showed it existed in the directory structure.</p>

<p>This is because <acronym title="Internet Information Services">IIS</acronym> doesn&#8217;t know what a <em>.properties</em> file is, or how it should be treated.  This is easily remedied.  In <acronym title="Internet Information Services">IIS</acronym> manager, either under the site, or at the root level, go to the <acronym title="Multipurpose Internet Mail Extension">MIME</acronym> option, and add it.  In this case, the file extension was .properties, and the <acronym title="Multipurpose Internet Mail Extension">MIME</acronym> Type was specified as <em>application/octet-stream</em>. If it&#8217;s done at the root server level, it applies to all sites.  If you do it on a site, it only applies to the site you changed it on.  No resets, or such, required.  Now the file is served properly.</p>

<p>Microsoft has this documented on <a href="http://support.microsoft.com/kb/326965" title="Microsoft; KB326965">KB326965</a>.  Whilst this applies to IIS6, the same applies to IIS7 as well.  To save some waiting in IIS7, you can use the appcmd to add the type for you&#8230;</p>

<div class="codecolorer-container dos default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="dos codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">appcmd <a href="http://www.ss64.com/nt/set.html"><span style="color: #b1b100; font-weight: bold;">set</span></a> config /section:staticContent /+&quot;<span style="color: #66cc66;">&#91;</span>fileExtension='.properties',mimeType='application/octet-stream'<span style="color: #66cc66;">&#93;</span>&quot;</div></div>

<p>This applies the setting at the root server level, and is usually inherited down to all sites.</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/06/17/iis-and-unknown-file-types/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maintenance Windows, and communicating your times&#8230;</title>
		<link>http://jon.netdork.net/2010/06/14/maintenance-windows-and-communicating-your-times?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=maintenance-windows-and-communicating-your-times</link>
		<comments>http://jon.netdork.net/2010/06/14/maintenance-windows-and-communicating-your-times#comments</comments>
		<pubDate>Tue, 15 Jun 2010 04:31:41 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[General Ramblings]]></category>
		<category><![CDATA[Maintenance]]></category>
		<category><![CDATA[SysAdmin]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=859</guid>
		<description><![CDATA[Bob Plankers of The Lone Sysadmin fame, has an excellent article titled Midnight is Always Tomorrow, which talks about communicating maintenance windows effectively with peers, as well as customers. He describes the confusion between the term of Midnight, and how some people consider it one day, whilst others see it as a different day. Midnight [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F14%2Fmaintenance-windows-and-communicating-your-times">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F14%2Fmaintenance-windows-and-communicating-your-times&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly&amp;hashtags=Maintenance,SysAdmin" height="61" width="50" />
			</a>
		</div><p>Bob Plankers of <a href="http://lonesysadmin.net/" title="The Lone Sysadmin">The Lone Sysadmin</a> fame, has an excellent article titled <a href="http://lonesysadmin.net/2010/06/14/midnight-is-always-tomorrow/?utm_source=The+Geekery&amp;utm_medium=web&amp;utm_campaign=midnight+is+always+tomorrow" title="The Lone Sysadmin; Midnight is Always Tomorrow">Midnight is Always Tomorrow</a>, which talks about communicating maintenance windows effectively with peers, as well as customers.  He describes the confusion between the term of Midnight, and how some people consider it one day, whilst others see it as a different day.</p>

<blockquote>
<b>Midnight is 00:00, meaning the start of a new day. Always.</b><br /><br />

If you’re in doubt, use 00:01. Assume everybody is clueless about time, because they are. For example, a lot of people think in terms of when they go to sleep, not what actual time it is, so if they’re still up at 0200 on Sunday they consider it to be Saturday.
</blockquote>

<p>He timed it well, I was thinking of posting about this very subject myself after a similar incident last week.  After our QA team had cleared a break-fix release, it was scheduled for that fateful time, on Midnight on Friday.  This was discussed at length by several people on Monday.  After several meetings, I hear somebody walking past, telling the business units on Wednesday&#8230;</p>

<blockquote>
Yes, it&#8217;ll be released tonight, and ready for tomorrow.
</blockquote>

<p>&#8220;Tonight&#8221; would have been Wednesday night, tomorrow would have been Thursday.  Somehow the magical shift of midnight pushed the release forward a day.  Fortunately we interjected, and had them corrected.  </p>

<p>This isn&#8217;t the only incident that is like this, we see it frequently when something gets requested for that time. I cannot begin to count the number of times I&#8217;ve had somebody ask me &#8220;is the release tonight at 2am?&#8221;. This goes into the idea that people consider &#8220;tonight&#8221; to be anytime before they went to sleep.</p>

<p>Going with Bob&#8217;s suggestion, use dates, and 24 hour clocks, if necessary (and always recommended) shift the time by a few minutes to make it obvious which date <em>midnight</em> falls on.  Notify customers, tell them the outage/maintenance/changes are at 00:05 on 06/15/2010 (if you work with international customers, use words instead of numbers).</p>

<p>Bob finishes on a perfect example&#8230;</p>

<blockquote>
<i>
“The system shutdowns will commence at 2200 on 4/17/2010, the power will be disconnected at 0000 on 4/18/2010, and power-ups will occur again at 0800 on 4/18/2010. All times are in CDT (-0500).”
</i>
</blockquote>

<p>Be clear. Be concise. Be exact. Remove as much ambiguity as you can. The customers will be happy for it.</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/06/14/maintenance-windows-and-communicating-your-times/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>PowerShell; Calculated values in results</title>
		<link>http://jon.netdork.net/2010/06/11/powershell-calculated-values-in-results?utm_source=rss&amp;utm_medium=rss&amp;utm_campaign=powershell-calculated-values-in-results</link>
		<comments>http://jon.netdork.net/2010/06/11/powershell-calculated-values-in-results#comments</comments>
		<pubDate>Fri, 11 Jun 2010 09:41:51 +0000</pubDate>
		<dc:creator>Jonathan Angliss</dc:creator>
				<category><![CDATA[PowerShell]]></category>

		<guid isPermaLink="false">http://jon.netdork.net/?p=848</guid>
		<description><![CDATA[Whilst sitting here on a product release call, I was reading over my twitter feed, specifically looking at #powershell, and I saw a post by @tonjoh. Feeling I had a few minutes on my hands whilst QA bashed away at the servers, I decided to take a look&#8230; I&#8217;m not sure what WMI counter is [...]]]></description>
			<content:encoded><![CDATA[<!-- google_ad_section_start --><div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F11%2Fpowershell-calculated-values-in-results">
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjon.netdork.net%2F2010%2F06%2F11%2Fpowershell-calculated-values-in-results&amp;source=j_angliss&amp;style=normal&amp;service=bit.ly" height="61" width="50" />
			</a>
		</div><p>Whilst sitting here on a product release call, I was reading over my twitter feed, specifically looking at <a href="http://twitter.com/#search?q=powershell" title="Twitter Search; PowerShell">#powershell</a>, and I saw a post by <a href="http://twitter.com/tonjoh/statuses/15915032860" title="Twitter; tonjoh">@tonjoh</a>.  Feeling I had a few minutes on my hands whilst QA bashed away at the servers, I decided to take a look&#8230;</p>

<p><span id="more-848"></span></p>

<p>I&#8217;m not sure what <acronym title="Windows Management Instrumentation">WMI</acronym> counter is being used as I cannot find one called free-diskspace-query, but I do know there is a Win32_LogicalDisk, which has enough information in it to tell us free space.  So here we go&#8230; Lets just get the information we want first, and build up from there&#8230;</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-weight: bold;">Get-WmiObject</span> Win32_LogicalDisk <span style="color: pink;">|</span> <span style="color: #008080; font-weight: bold;">Format-Table</span> DeviceId<span style="color: pink;">,</span> Size<span style="color: pink;">,</span> FreeSpace</div></div>

<p>This is pretty simple, and can probably be found as an example all over the place.  For the curious, the output looks like this:</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DeviceId &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Size &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; FreeSpace<br />
<span style="color: pink;">--------</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: pink;">----</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: pink;">---------</span><br />
C: &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #804000;">119941029888</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #804000;">48341823488</span></div></div>

<p>So we can see the size (~111GB), and the amount of free space (~45GB).  Now onto the fun stuff, using expressions.</p>

<p>Expressions allow us to do calculations on the resultset that came back from the pre-piped data.  This can be something like calculating a percentage, or throwing in miscellaneous data (like requested, a timestamp).</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #008080; font-weight: bold;">Get-WmiObject</span> Win32_LogicalDisk <span style="color: pink;">|</span> `<br />
&nbsp; &nbsp; <span style="color: #008080; font-weight: bold;">Format-Table</span> DeviceId<span style="color: pink;">,</span> Size<span style="color: pink;">,</span> FreeSpace<span style="color: pink;">,</span> `<br />
&nbsp; &nbsp; <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>Name<span style="color: pink;">=</span><span style="color: #800000;">&quot;PercFree&quot;</span>;Expression<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#91;</span><span style="color: #008080;">int</span><span style="color: #000000;">&#93;</span><span style="color: #000000;">&#40;</span><a href="about:blank"><span style="color: #000080;">$_</span></a>.FreeSpace<span style="color: pink;">/</span><a href="about:blank"><span style="color: #000080;">$_</span></a>.Size <span style="color: pink;">*</span> <span style="color: #804000;">100</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span><span style="color: pink;">,</span> `<br />
&nbsp; &nbsp; <span style="color: pink;">@</span><span style="color: #000000;">&#123;</span>Name<span style="color: pink;">=</span><span style="color: #800000;">&quot;ReportDate&quot;</span>;Expression<span style="color: pink;">=</span><span style="color: #000000;">&#123;</span><span style="color: #000000;">&#40;</span><span style="color: #008080; font-weight: bold;">Get-Date</span> <span style="color: #008080; font-style: italic;">-Format</span> <span style="color: #800000;">&quot;yyyyMMdd-HHMMss&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#125;</span><span style="color: #000000;">&#125;</span></div></div>

<p>In the above code, I&#8217;ve used the back-tick (`) to wrap the lines, and make it easier to read.  PowerShell understands this, and will treat the 4 lines as one.  I&#8217;ve created 2 extra, named, columns, one PercFree, and the other ReportDate.  The expression in the first is a calculation based on the values from the Win32_LogicalDisk output, whilst the expression for the second is just <em>extra</em> data in the form of a formatted date.  With the above code, you get the following&#8230;</p>

<div class="codecolorer-container posh default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="posh codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">DeviceId &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Size &nbsp; &nbsp;FreeSpace &nbsp; PercFree ReportDate &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
<span style="color: pink;">--------</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: pink;">----</span> &nbsp; &nbsp;<span style="color: pink;">---------</span> &nbsp; <span style="color: pink;">--------</span> <span style="color: pink;">----------</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br />
C: &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #804000;">119941029888</span> &nbsp;<span style="color: #804000;">48297115648</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #804000;">40</span> <span style="color: #804000;">20100611</span><span style="color: pink;">-</span>040646</div></div>

<p>And there we have it, two extra columns, which were calculated on the fly.</p><!-- google_ad_section_end -->]]></content:encoded>
			<wfw:commentRss>http://jon.netdork.net/2010/06/11/powershell-calculated-values-in-results/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
