<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>Precision Computing</title>
    <link>http://www.leeholmes.com/blog/</link>
    <description>Software Design and Development</description>
    <copyright>Lee Holmes</copyright>
    <lastBuildDate>Wed, 25 Jun 2008 04:17:45 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>blog-feedback@leeholmes.com</managingEditor>
    <webMaster>blog-feedback@leeholmes.com</webMaster>
    <item>
      <trackback:ping>http://www.leeholmes.com/blog/Trackback.aspx?guid=888bbfc9-b0e2-4e67-9e6b-b264f74e2a01</trackback:ping>
      <pingback:server>http://www.leeholmes.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.leeholmes.com/blog/PermaLink,guid,888bbfc9-b0e2-4e67-9e6b-b264f74e2a01.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.leeholmes.com/blog/CommentView,guid,888bbfc9-b0e2-4e67-9e6b-b264f74e2a01.aspx</wfw:comment>
      <wfw:commentRss>http://www.leeholmes.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=888bbfc9-b0e2-4e67-9e6b-b264f74e2a01</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Last night, I flew my first half-hour as Pilot in Command of N8756C, a 1977 Piper
Warrior. In flying, a pilot’s <a href="http://en.wikipedia.org/wiki/First_solo_flight">First
Solo</a> is a huge milestone. After hours of training and ground study, you finally
take to the air on your own.
</p>
        <p align="center">
          <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="184" alt="FirstSolo" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/P1010091_1.jpg" width="244" border="0" />
        </p>
        <p>
The most difficult part of flying is getting back down, so the First Solo is three
takeoffs and landings -- about half-an-hour in the traffic pattern. It seemed to be
the flight that would never come, though. 
</p>
        <p>
We first planned our pre-solo flight for Thursday, followed by the solo on Sunday.
The pre-solo flight is a comprehensive review, so we booked the airplane from 5 to
7 PM. When we went through our pre-flight checklist, we realized that none of the
avionics were working: I could hear myself, but couldn’t speak with my instructor.
We tried everything we could to resolve the problem (including accidentally enabling
the Emergency Locator Transmitter / Distress Beacon,) but couldn’t fix it. Dejected,
we re-parked the plane and returned to base. I later learned that the squelch on the
radio was wrongly adjusted. The squelch control determines the signal strength required
for transmission. It is normally used to suppress low-level static, but in this case
was set to exclude almost everything. 
</p>
        <p>
With that flight aside, we re-booked for Sunday – this time for both the pre-solo
and solo flight. 
</p>
        <p>
Sunday came around bright and sunny, as did our 6 PM flight time. We patiently waited
for our plane to arrive back from a previous lesson, filling time with some ground
work in the meantime. We planned a flight to <a href="http://www.airnav.com/airport/KPLU">Thun
Field</a>, with detours for maneuver practice and instrument flying. Then, we waited
some more. And some more. The plane finally got back 75 minutes late, but we went
out hoping to get at least part of the lesson done. 
</p>
        <p>
When we got to the plane for our pre-flight checklist, we of course found it bone-dry.
The gas truck took seemed to take its sweet time, but the real kicker came as we prepared
to taxi out of the parking area. There was traffic to our left: a brand spanking new <a href="http://en.wikipedia.org/wiki/Boeing_737">Boeing
737</a> being towed SLOWLY back toward the Boeing hangar in all of its <a href="http://blog.seattle-deliveries.com/2008/01/skymark-737-ja737p-pic.html">unpainted
glory</a>. By slowly, I mean walking pace. This taxi would have taken 45 or 50 minutes,
so we had to call off that flight, as well. We re-booked for Monday: 5 to 9 PM. 
</p>
        <p align="center">
          <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="164" alt="Boeing 737" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/clip_image001_3.jpg" width="244" border="0" />
        </p>
        <p>
Monday (yesterday) finally came around, and my study work for Sunday night was to
read up on how to use the <a href="http://en.wikipedia.org/wiki/VHF_omnidirectional_range">VOR
system</a> for navigation, rather than use the primarily visual navigation we were
previously planning. VORs are directional beacons that let a flight instrument determine
the direction from the VOR ground station to your airplane. To find a specific point,
you generally use two VORs at the same time to triangulate your position. 
</p>
        <p>
The flight was intense. It was 2.8 hours in the air and reviewed: 
</p>
        <ul>
          <li>
Slow flight, where you fly and maneuver at near-stall speeds 
</li>
          <li>
Power-On and Power-Off stalls, and stall recovery 
</li>
          <li>
Ground reference maneuvers (Turns around a point, S-turns, rectangular courses) 
</li>
          <li>
Steep turns and standard turns</li>
          <li>
Emergency procedures (We “lost our engine,” so I had to pick and prepare
for a landing) 
</li>
          <li>
Go-Arounds (Calling a mulligan on un-safe or un-certain landings) 
</li>
          <li>
5 landings at Thun field, with my instructor having his eyes closed for the final
3 or 4 
</li>
        </ul>
        <p>
I was recording this on my GPS, so here are some highlights. First, the Thun Field
landings:
</p>
        <p>
          <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="Thun Field landings" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/image_3.png" width="208" border="0" />
        </p>
        <p>
Then, some ground-reference maneuvres:
</p>
        <p>
          <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="182" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/image_6.png" width="244" border="0" />
        </p>
        <p>
On the way back to Renton airport, we also did 30 minutes of Instrument Training.
For instrument training, you don a mask that prevents you from seeing outside the
cockpit, and maneuver the airplane by instruments alone. 
</p>
        <p>
When we finally landed back at Renton airport, we practiced another 2 landings, finally
coming to a full stop at the tie-down area. My instructor got out, wished me luck,
and watched as went through the pre-flight checklist again. I alerted the tower as
I prepared to taxi: 
</p>
        <blockquote>
          <p>
            <i>Renton Ground, this is Warrior 8756 Charlie at North Tower. Student pilot on first
solo, requesting closed traffic with information Alpha.</i>
          </p>
        </blockquote>
        <p>
I was given clearance to taxi to runway 15 (150 degrees, roughly north to south,)
and prepared for my first flight. I waited for a minute as a few other planes landed,
and then was given clearance for takeoff. I had too much power on my first run around
the traffic pattern, so ended up lining up with the runway a little too high. Rather
than try to rescue the landing in a potentially nervous state, I let the tower know
I was doing a go-around, and climbed back to the traffic pattern. The controller mentioned
that the winds were fairly variable and gusty, approaching 8 knots at times. She offered
the south to north landing on runway 33, which I declined (as the winds weren’t
affecting my landings.) The second attempt was much better, marking my first landing
as Pilot in Command. 
</p>
        <p>
Now for landing number two. 
</p>
        <p>
Take-off is usually a breeze, but the nose appeared unusually high as I gave the plane
full power on the ground. I quickly brought the power down, and exited one of the
taxiways to determine the cause. After checking everything (flaps, elevator, etc,)
I realized it was just a mind trick: I had been in a basically nose-down attitude
(for the descents) for the last 10 or 15 minutes, so it was a lot like Velocitization
in a car. You get so used to something (speed in a car, or nose angle in an airplane,)
that it becomes your mind’s new definition of normal. You combat velocitization
once you realize you have it, so I requested clearance to taxi back on the runway
and complete my landings. 
</p>
        <p>
In the air again, the controller mentioned that they were just about to close, and
asked if I wanted her to stay on. I didn’t want to keep her late, so I let her
know I’d make my next landing a full-stop. She was awesome, and said she had
no problem staying so I could get the solo done, so I continued with my next landing
– still OK, but with definite room for improvement. 
</p>
        <p>
My final takeoff is where it really kicked in. After lifting into the air, an enormous
thrill washed over me as I took a relaxed breath of fresh air. It was physically impossible
for me to NOT land a third time. I grinned as I made my final approach, and settled
in for the smoothest and straightest landing yet.
</p>
        <p>
As recorded by my GPS:
</p>
        <p>
          <a href="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/image_8.png">
            <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="484" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/image_thumb_2.png" width="461" border="0" />
          </a>  
</p>
        <p>
As I taxied off the runway, the tower controller congratulated me on my landings as
I thanked her for her help. The landings were nothing for the highlight reels, of
course, but it gave a satisfying end-cap to 30 minutes that I will never forget. 
</p>
        <p>
And the ripped shirt to prove it? Well, in-line with tradition, my instructor <a href="http://flighttraining.aopa.org/ft_magazine/special/shirttails.cfm">cut
up the back of my shirt</a>. Before modern electronics, in-cockpit communication was
mainly through shirt tugging and hollers from the instructor that sat behind you.
Cutting off the back of the shirt symbolizes this very important step -- as your instructor
won't need to be yanking on it any more.
</p>
        <img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=888bbfc9-b0e2-4e67-9e6b-b264f74e2a01" />
      </body>
      <title>First Solo &amp;ndash; and a Ripped Shirt to Prove It</title>
      <guid isPermaLink="false">http://www.leeholmes.com/blog/PermaLink,guid,888bbfc9-b0e2-4e67-9e6b-b264f74e2a01.aspx</guid>
      <link>http://www.leeholmes.com/blog/FirstSoloNdashAndARippedShirtToProveIt.aspx</link>
      <pubDate>Wed, 25 Jun 2008 04:17:45 GMT</pubDate>
      <description>&lt;p&gt;
Last night, I flew my first half-hour as Pilot in Command of N8756C, a 1977 Piper
Warrior. In flying, a pilot&amp;#8217;s &lt;a href="http://en.wikipedia.org/wiki/First_solo_flight"&gt;First
Solo&lt;/a&gt; is a huge milestone. After hours of training and ground study, you finally
take to the air on your own.
&lt;/p&gt;
&lt;p align="center"&gt;
&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="184" alt="FirstSolo" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/P1010091_1.jpg" width="244" border="0" /&gt; 
&lt;/p&gt;
&lt;p&gt;
The most difficult part of flying is getting back down, so the First Solo is three
takeoffs and landings -- about half-an-hour in the traffic pattern. It seemed to be
the flight that would never come, though. 
&lt;/p&gt;
&lt;p&gt;
We first planned our pre-solo flight for Thursday, followed by the solo on Sunday.
The pre-solo flight is a comprehensive review, so we booked the airplane from 5 to
7 PM. When we went through our pre-flight checklist, we realized that none of the
avionics were working: I could hear myself, but couldn&amp;#8217;t speak with my instructor.
We tried everything we could to resolve the problem (including accidentally enabling
the Emergency Locator Transmitter / Distress Beacon,) but couldn&amp;#8217;t fix it. Dejected,
we re-parked the plane and returned to base. I later learned that the squelch on the
radio was wrongly adjusted. The squelch control determines the signal strength required
for transmission. It is normally used to suppress low-level static, but in this case
was set to exclude almost everything. 
&lt;/p&gt;
&lt;p&gt;
With that flight aside, we re-booked for Sunday &amp;#8211; this time for both the pre-solo
and solo flight. 
&lt;/p&gt;
&lt;p&gt;
Sunday came around bright and sunny, as did our 6 PM flight time. We patiently waited
for our plane to arrive back from a previous lesson, filling time with some ground
work in the meantime. We planned a flight to &lt;a href="http://www.airnav.com/airport/KPLU"&gt;Thun
Field&lt;/a&gt;, with detours for maneuver practice and instrument flying. Then, we waited
some more. And some more. The plane finally got back 75 minutes late, but we went
out hoping to get at least part of the lesson done. 
&lt;/p&gt;
&lt;p&gt;
When we got to the plane for our pre-flight checklist, we of course found it bone-dry.
The gas truck took seemed to take its sweet time, but the real kicker came as we prepared
to taxi out of the parking area. There was traffic to our left: a brand spanking new &lt;a href="http://en.wikipedia.org/wiki/Boeing_737"&gt;Boeing
737&lt;/a&gt; being towed SLOWLY back toward the Boeing hangar in all of its &lt;a href="http://blog.seattle-deliveries.com/2008/01/skymark-737-ja737p-pic.html"&gt;unpainted
glory&lt;/a&gt;. By slowly, I mean walking pace. This taxi would have taken 45 or 50 minutes,
so we had to call off that flight, as well. We re-booked for Monday: 5 to 9 PM. 
&lt;/p&gt;
&lt;p align="center"&gt;
&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="164" alt="Boeing 737" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/clip_image001_3.jpg" width="244" border="0" /&gt;
&lt;/p&gt;
&lt;p&gt;
Monday (yesterday) finally came around, and my study work for Sunday night was to
read up on how to use the &lt;a href="http://en.wikipedia.org/wiki/VHF_omnidirectional_range"&gt;VOR
system&lt;/a&gt; for navigation, rather than use the primarily visual navigation we were
previously planning. VORs are directional beacons that let a flight instrument determine
the direction from the VOR ground station to your airplane. To find a specific point,
you generally use two VORs at the same time to triangulate your position. 
&lt;/p&gt;
&lt;p&gt;
The flight was intense. It was 2.8 hours in the air and reviewed: 
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Slow flight, where you fly and maneuver at near-stall speeds 
&lt;/li&gt;
&lt;li&gt;
Power-On and Power-Off stalls, and stall recovery 
&lt;/li&gt;
&lt;li&gt;
Ground reference maneuvers (Turns around a point, S-turns, rectangular courses) 
&lt;/li&gt;
&lt;li&gt;
Steep turns and standard turns&lt;/li&gt;
&lt;li&gt;
Emergency procedures (We &amp;#8220;lost our engine,&amp;#8221; so I had to pick and prepare
for a landing) 
&lt;/li&gt;
&lt;li&gt;
Go-Arounds (Calling a mulligan on un-safe or un-certain landings) 
&lt;/li&gt;
&lt;li&gt;
5 landings at Thun field, with my instructor having his eyes closed for the final
3 or 4 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I was recording this on my GPS, so here are some highlights. First, the Thun Field
landings:
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="Thun Field landings" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/image_3.png" width="208" border="0" /&gt; 
&lt;/p&gt;
&lt;p&gt;
Then, some ground-reference maneuvres:
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="182" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/image_6.png" width="244" border="0" /&gt; 
&lt;/p&gt;
&lt;p&gt;
On the way back to Renton airport, we also did 30 minutes of Instrument Training.
For instrument training, you don a mask that prevents you from seeing outside the
cockpit, and maneuver the airplane by instruments alone. 
&lt;/p&gt;
&lt;p&gt;
When we finally landed back at Renton airport, we practiced another 2 landings, finally
coming to a full stop at the tie-down area. My instructor got out, wished me luck,
and watched as went through the pre-flight checklist again. I alerted the tower as
I prepared to taxi: 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;i&gt;Renton Ground, this is Warrior 8756 Charlie at North Tower. Student pilot on first
solo, requesting closed traffic with information Alpha.&lt;/i&gt; 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I was given clearance to taxi to runway 15 (150 degrees, roughly north to south,)
and prepared for my first flight. I waited for a minute as a few other planes landed,
and then was given clearance for takeoff. I had too much power on my first run around
the traffic pattern, so ended up lining up with the runway a little too high. Rather
than try to rescue the landing in a potentially nervous state, I let the tower know
I was doing a go-around, and climbed back to the traffic pattern. The controller mentioned
that the winds were fairly variable and gusty, approaching 8 knots at times. She offered
the south to north landing on runway 33, which I declined (as the winds weren&amp;#8217;t
affecting my landings.) The second attempt was much better, marking my first landing
as Pilot in Command. 
&lt;/p&gt;
&lt;p&gt;
Now for landing number two. 
&lt;/p&gt;
&lt;p&gt;
Take-off is usually a breeze, but the nose appeared unusually high as I gave the plane
full power on the ground. I quickly brought the power down, and exited one of the
taxiways to determine the cause. After checking everything (flaps, elevator, etc,)
I realized it was just a mind trick: I had been in a basically nose-down attitude
(for the descents) for the last 10 or 15 minutes, so it was a lot like Velocitization
in a car. You get so used to something (speed in a car, or nose angle in an airplane,)
that it becomes your mind&amp;#8217;s new definition of normal. You combat velocitization
once you realize you have it, so I requested clearance to taxi back on the runway
and complete my landings. 
&lt;/p&gt;
&lt;p&gt;
In the air again, the controller mentioned that they were just about to close, and
asked if I wanted her to stay on. I didn&amp;#8217;t want to keep her late, so I let her
know I&amp;#8217;d make my next landing a full-stop. She was awesome, and said she had
no problem staying so I could get the solo done, so I continued with my next landing
&amp;#8211; still OK, but with definite room for improvement. 
&lt;/p&gt;
&lt;p&gt;
My final takeoff is where it really kicked in. After lifting into the air, an enormous
thrill washed over me as I took a relaxed breath of fresh air. It was physically impossible
for me to NOT land a third time. I grinned as I made my final approach, and settled
in for the smoothest and straightest landing yet.
&lt;/p&gt;
&lt;p&gt;
As recorded by my GPS:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/image_8.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="484" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstSoloandaRippedShirttoProveIt_122A9/image_thumb_2.png" width="461" border="0" /&gt;&lt;/a&gt;&amp;#160; 
&lt;/p&gt;
&lt;p&gt;
As I taxied off the runway, the tower controller congratulated me on my landings as
I thanked her for her help. The landings were nothing for the highlight reels, of
course, but it gave a satisfying end-cap to 30 minutes that I will never forget. 
&lt;/p&gt;
&lt;p&gt;
And the ripped shirt to prove it? Well, in-line with tradition, my instructor &lt;a href="http://flighttraining.aopa.org/ft_magazine/special/shirttails.cfm"&gt;cut
up the back of my shirt&lt;/a&gt;. Before modern electronics, in-cockpit communication was
mainly through shirt tugging and hollers from the instructor that sat behind you.
Cutting off the back of the shirt symbolizes this very important step -- as your instructor
won't need to be yanking on it any more.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=888bbfc9-b0e2-4e67-9e6b-b264f74e2a01" /&gt;</description>
      <comments>http://www.leeholmes.com/blog/CommentView,guid,888bbfc9-b0e2-4e67-9e6b-b264f74e2a01.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.leeholmes.com/blog/Trackback.aspx?guid=680bc0bc-5b93-469c-8b64-be123744649b</trackback:ping>
      <pingback:server>http://www.leeholmes.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.leeholmes.com/blog/PermaLink,guid,680bc0bc-5b93-469c-8b64-be123744649b.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.leeholmes.com/blog/CommentView,guid,680bc0bc-5b93-469c-8b64-be123744649b.aspx</wfw:comment>
      <wfw:commentRss>http://www.leeholmes.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=680bc0bc-5b93-469c-8b64-be123744649b</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One question that comes up fairly often when dealing with (or writing!) secure cmdlets
is how to properly handle usernames and passwords. The solution there is to use (or
make) the -Credential parameter of type PSCredential. A PSCredential object helps
ensure that your password stays protected in memory, unlike cmdlets that accept a
straight username / password combination.
</p>
        <p>
If a parameter is of type PSCredential, PowerShell supports several types of input:
</p>
        <ul>
          <li>
empty: If you supply no input to a mandatory -Credential parameter, PowerShell prompts
you for the username and password.</li>
          <li>
string: If you supply a string to the -Credential parameter, PowerShell treats it
as a username and prompts you for the password.</li>
          <li>
credential: If you supply a credential object to the -Credential parameter, PowerShell
accepts it as-is.</li>
        </ul>
        <p>
This is great for interactive use, but what if you want to write an automated script
for a cmdlet that accepts a -Credential parameter? The solution lies in passing a
pre-constructed PSCredential object. The solution to this is covered by recipe 16.9
in the <a href="http://www.amazon.com/gp/product/0596528493?ie=UTF8&amp;tag=preciscomput-20&amp;link_code=as3&amp;camp=211189&amp;creative=373489&amp;creativeASIN=0596528493">PowerShell
Cookbook</a>:
</p>
        <p>
 
</p>
        <h1 style="text-align: justify">
          <a name="XREF86186_Securely_Store_Credentials_on_">Securely
Store Credentials on Disk</a>
          <p>
          </p>
        </h1>
        <h2 style="text-align: justify">Problem 
<p></p></h2>
        <p class="MsoBodyText">
Your script performs an operation that requires credentials, but you don’t want
it to require user interaction when it runs. 
</p>
        <p>
        </p>
        <h2 style="text-align: justify">Solution 
<p></p></h2>
        <p class="MsoBodyText">
To securely store the credential’s password to disk so that your script can
load it automatically, use the <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">ConvertFrom-SecureString</span></span> and <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">ConvertTo-SecureString</span></span> cmdlets. 
</p>
        <p>
        </p>
        <h3>Save the credential’s password to disk 
<p></p></h3>
        <p class="MsoBodyText">
The first step for storing a password on disk is usually a manual one. Given a credential
that you’ve stored in the <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">$credential</span></span> variable,
you can safely export its password to <span class="Filename"><span style="mso-bidi-font-family: 'Times New Roman'">password.txt</span></span> using
the following command: 
</p>
        <p>
        </p>
        <div style="border-right: medium none; padding-right: 0in; border-top: medium none; padding-left: 2pt; padding-bottom: 0in; margin-left: 0.25in; border-left: windowtext 1pt solid; margin-right: -67.7pt; padding-top: 0in; border-bottom: medium none; mso-element: para-border-div; mso-border-left-alt: solid windowtext .75pt">
          <p class="Code" style="margin: 0in 0in 0pt">
PS &gt;$credential.Password | ConvertFrom-SecureString | Set-Content <span class="Replaceable"><span style="mso-bidi-font-family: 'Times New Roman'">c:\temp\password.txt</span></span></p>
          <p>
          </p>
        </div>
        <h3>Recreate the credential from the password stored on disk 
<p></p></h3>
        <p class="MsoBodyText">
In the script that you want to run automatically, add the following commands: 
</p>
        <p>
        </p>
        <div style="border-right: medium none; padding-right: 0in; border-top: medium none; padding-left: 2pt; padding-bottom: 0in; margin-left: 0.25in; border-left: windowtext 1pt solid; margin-right: -67.7pt; padding-top: 0in; border-bottom: medium none; mso-element: para-border-div; mso-border-left-alt: solid windowtext .75pt">
          <p class="Code" style="margin: 0in 0in 0pt">
$password = Get-Content <span class="Replaceable"><span style="mso-bidi-font-family: 'Times New Roman'">c:\temp\password.txt</span></span> |
ConvertTo-SecureString 
</p>
          <p>
          </p>
          <p class="Code" style="margin: 0in 0in 0pt">
$credential = New-Object System.Management.Automation.PsCredential ` 
</p>
          <p>
          </p>
          <p class="Code" style="margin: 0in 0in 0pt">
            <span style="mso-spacerun: yes">    </span>"<span class="Replaceable"><span style="mso-bidi-font-family: 'Times New Roman'">CachedUser</span></span>",$password 
</p>
          <p>
          </p>
        </div>
        <p class="MsoBodyText">
These commands create a new credential object (for the <span class="Replaceable"><span style="mso-bidi-font-family: 'Times New Roman'">CachedUser</span></span> user)
and store that object in the <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">$credential</span></span> variable. 
</p>
        <p>
        </p>
        <h2>Discussion 
<p></p></h2>
        <p class="MsoBodyText">
When reading the solution, you might at first be wary of storing a password on disk.
While it is natural (and prudent) to be cautious of littering your hard drive with
sensitive information, the <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">ConvertFrom-SecureString</span></span> cmdlet
encrypts this data using Windows’ standard <span class="TechnicalItalic"><span style="mso-bidi-font-family: 'Times New Roman'">Data
Protection API</span></span>. This ensures that only your user account can properly
decrypt its contents. 
</p>
        <p>
        </p>
        <p class="MsoBodyText">
While keeping a password secure is an important security feature, you may sometimes
want to store a password (or other sensitive information) on disk so that other accounts
have access to it anyway. This is often the case with scripts run by service accounts
or scripts designed to be transferred between computers. The <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">ConvertFrom-SecureString</span></span> and <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">ConvertTo-SecureString</span></span> cmdlets
support this by allowing you to specify an encryption key. 
</p>
        <p>
        </p>
        <div style="border-right: medium none; padding-right: 0in; border-top: windowtext 1pt solid; padding-left: 0in; padding-bottom: 2pt; margin-left: 0.5in; border-left: medium none; margin-right: 0.5in; padding-top: 2pt; border-bottom: windowtext 1pt solid; mso-element: para-border-div; mso-border-top-alt: solid windowtext .75pt; mso-border-bottom-alt: solid windowtext .75pt">
          <p class="Note" style="margin: 6pt 0in">
When used with a hard-coded encryption key, this technique no longer acts as a security
measure. If a user can access to the content of your automated script, they have access
to the encryption key. If the user has access to the encryption key, they have access
to the data you were trying to protect. 
</p>
          <p>
          </p>
        </div>
        <p class="MsoBodyText">
Although the solution stores the password in a specific named file, it is more common
to store the file in a more generic location—such as the directory that contains
the script, or the directory that contains your profile. 
</p>
        <p>
        </p>
        <p class="MsoBodyText">
To load <span class="Filename"><span style="mso-bidi-font-family: 'Times New Roman'">password.txt</span></span> from
the same location as your profile, use the following command: 
</p>
        <p>
        </p>
        <div style="border-right: medium none; padding-right: 0in; border-top: medium none; padding-left: 2pt; padding-bottom: 0in; margin-left: 0.25in; border-left: windowtext 1pt solid; margin-right: -67.7pt; padding-top: 0in; border-bottom: medium none; mso-element: para-border-div; mso-border-left-alt: solid windowtext .75pt">
          <p class="Code" style="margin: 0in 0in 0pt">
$passwordFile = Join-Path (Split-Path $profile) password.txt 
</p>
          <p>
          </p>
          <p class="Code" style="margin: 0in 0in 0pt">
$password = Get-Content $passwordFile | ConvertTo-SecureString 
</p>
          <p>
          </p>
        </div>
        <p class="MsoBodyText">
To learn how to load it from the same location as your script, see “<a name="XREF93954_Find_your_Scripts_Location">Find
your Script’s Location</a>.” 
</p>
        <p>
        </p>
        <p class="MsoBodyText">
For more information about the <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">ConvertTo-SecureString</span></span> and <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">ConvertFrom-SecureString</span></span> cmdlets,
type <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">Get-Help
ConvertTo-SecureString</span></span> or <span class="Literal"><span style="mso-bidi-font-family: 'Times New Roman'">Get-Help
ConvertFrom-SecureString</span></span>. 
</p>
        <img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=680bc0bc-5b93-469c-8b64-be123744649b" />
      </body>
      <title>Importing and Exporting Credentials in PowerShell</title>
      <guid isPermaLink="false">http://www.leeholmes.com/blog/PermaLink,guid,680bc0bc-5b93-469c-8b64-be123744649b.aspx</guid>
      <link>http://www.leeholmes.com/blog/ImportingAndExportingCredentialsInPowerShell.aspx</link>
      <pubDate>Wed, 04 Jun 2008 15:40:28 GMT</pubDate>
      <description>&lt;p&gt;
One question that comes up fairly often when dealing with (or writing!) secure cmdlets
is how to properly handle usernames and passwords. The solution there is to use (or
make) the -Credential parameter of type PSCredential. A PSCredential object helps
ensure that your password stays protected in memory, unlike cmdlets that accept a
straight username / password combination.
&lt;/p&gt;
&lt;p&gt;
If a parameter is of type PSCredential, PowerShell supports several types of input:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
empty: If you supply no input to a mandatory -Credential parameter, PowerShell prompts
you for the username and password.&lt;/li&gt;
&lt;li&gt;
string: If you supply a string to the -Credential parameter, PowerShell treats it
as a username and prompts you for the password.&lt;/li&gt;
&lt;li&gt;
credential: If you supply a credential object to the -Credential parameter, PowerShell
accepts it as-is.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
This is great for interactive use, but what if you want to write an automated script
for a cmdlet that accepts a -Credential parameter? The solution lies in passing a
pre-constructed PSCredential object. The solution to this is covered by recipe 16.9
in the &lt;a href="http://www.amazon.com/gp/product/0596528493?ie=UTF8&amp;amp;tag=preciscomput-20&amp;amp;link_code=as3&amp;amp;camp=211189&amp;amp;creative=373489&amp;amp;creativeASIN=0596528493"&gt;PowerShell
Cookbook&lt;/a&gt;:
&lt;/p&gt;
&lt;p&gt;
&amp;#160;
&lt;/p&gt;
&lt;h1 style="text-align: justify"&gt;&lt;a name="XREF86186_Securely_Store_Credentials_on_"&gt;Securely
Store Credentials on Disk&lt;/a&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;/h1&gt;
&lt;h2 style="text-align: justify"&gt;Problem 
&lt;p&gt;
&lt;/p&gt;
&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;
Your script performs an operation that requires credentials, but you don&amp;#8217;t want
it to require user interaction when it runs. 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;h2 style="text-align: justify"&gt;Solution 
&lt;p&gt;
&lt;/p&gt;
&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;
To securely store the credential&amp;#8217;s password to disk so that your script can
load it automatically, use the &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;ConvertFrom-SecureString&lt;/span&gt;&lt;/span&gt; and &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;ConvertTo-SecureString&lt;/span&gt;&lt;/span&gt; cmdlets. 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;h3&gt;Save the credential&amp;#8217;s password to disk 
&lt;p&gt;
&lt;/p&gt;
&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;
The first step for storing a password on disk is usually a manual one. Given a credential
that you&amp;#8217;ve stored in the &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;$credential&lt;/span&gt;&lt;/span&gt; variable,
you can safely export its password to &lt;span class="Filename"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;password.txt&lt;/span&gt;&lt;/span&gt; using
the following command: 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;div style="border-right: medium none; padding-right: 0in; border-top: medium none; padding-left: 2pt; padding-bottom: 0in; margin-left: 0.25in; border-left: windowtext 1pt solid; margin-right: -67.7pt; padding-top: 0in; border-bottom: medium none; mso-element: para-border-div; mso-border-left-alt: solid windowtext .75pt"&gt;
&lt;p class="Code" style="margin: 0in 0in 0pt"&gt;
PS &amp;gt;$credential.Password | ConvertFrom-SecureString | Set-Content &lt;span class="Replaceable"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;c:\temp\password.txt&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;/div&gt;
&lt;h3&gt;Recreate the credential from the password stored on disk 
&lt;p&gt;
&lt;/p&gt;
&lt;/h3&gt;
&lt;p class="MsoBodyText"&gt;
In the script that you want to run automatically, add the following commands: 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;div style="border-right: medium none; padding-right: 0in; border-top: medium none; padding-left: 2pt; padding-bottom: 0in; margin-left: 0.25in; border-left: windowtext 1pt solid; margin-right: -67.7pt; padding-top: 0in; border-bottom: medium none; mso-element: para-border-div; mso-border-left-alt: solid windowtext .75pt"&gt;
&lt;p class="Code" style="margin: 0in 0in 0pt"&gt;
$password = Get-Content &lt;span class="Replaceable"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;c:\temp\password.txt&lt;/span&gt;&lt;/span&gt; |
ConvertTo-SecureString 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;p class="Code" style="margin: 0in 0in 0pt"&gt;
$credential = New-Object System.Management.Automation.PsCredential ` 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;p class="Code" style="margin: 0in 0in 0pt"&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;/span&gt;&amp;quot;&lt;span class="Replaceable"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;CachedUser&lt;/span&gt;&lt;/span&gt;&amp;quot;,$password 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;
These commands create a new credential object (for the &lt;span class="Replaceable"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;CachedUser&lt;/span&gt;&lt;/span&gt; user)
and store that object in the &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;$credential&lt;/span&gt;&lt;/span&gt; variable. 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;h2&gt;Discussion 
&lt;p&gt;
&lt;/p&gt;
&lt;/h2&gt;
&lt;p class="MsoBodyText"&gt;
When reading the solution, you might at first be wary of storing a password on disk.
While it is natural (and prudent) to be cautious of littering your hard drive with
sensitive information, the &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;ConvertFrom-SecureString&lt;/span&gt;&lt;/span&gt; cmdlet
encrypts this data using Windows&amp;#8217; standard &lt;span class="TechnicalItalic"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;Data
Protection API&lt;/span&gt;&lt;/span&gt;. This ensures that only your user account can properly
decrypt its contents. 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;p class="MsoBodyText"&gt;
While keeping a password secure is an important security feature, you may sometimes
want to store a password (or other sensitive information) on disk so that other accounts
have access to it anyway. This is often the case with scripts run by service accounts
or scripts designed to be transferred between computers. The &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;ConvertFrom-SecureString&lt;/span&gt;&lt;/span&gt; and &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;ConvertTo-SecureString&lt;/span&gt;&lt;/span&gt; cmdlets
support this by allowing you to specify an encryption key. 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;div style="border-right: medium none; padding-right: 0in; border-top: windowtext 1pt solid; padding-left: 0in; padding-bottom: 2pt; margin-left: 0.5in; border-left: medium none; margin-right: 0.5in; padding-top: 2pt; border-bottom: windowtext 1pt solid; mso-element: para-border-div; mso-border-top-alt: solid windowtext .75pt; mso-border-bottom-alt: solid windowtext .75pt"&gt;
&lt;p class="Note" style="margin: 6pt 0in"&gt;
When used with a hard-coded encryption key, this technique no longer acts as a security
measure. If a user can access to the content of your automated script, they have access
to the encryption key. If the user has access to the encryption key, they have access
to the data you were trying to protect. 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;
Although the solution stores the password in a specific named file, it is more common
to store the file in a more generic location&amp;#8212;such as the directory that contains
the script, or the directory that contains your profile. 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;p class="MsoBodyText"&gt;
To load &lt;span class="Filename"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;password.txt&lt;/span&gt;&lt;/span&gt; from
the same location as your profile, use the following command: 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;div style="border-right: medium none; padding-right: 0in; border-top: medium none; padding-left: 2pt; padding-bottom: 0in; margin-left: 0.25in; border-left: windowtext 1pt solid; margin-right: -67.7pt; padding-top: 0in; border-bottom: medium none; mso-element: para-border-div; mso-border-left-alt: solid windowtext .75pt"&gt;
&lt;p class="Code" style="margin: 0in 0in 0pt"&gt;
$passwordFile = Join-Path (Split-Path $profile) password.txt 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;p class="Code" style="margin: 0in 0in 0pt"&gt;
$password = Get-Content $passwordFile | ConvertTo-SecureString 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;/div&gt;
&lt;p class="MsoBodyText"&gt;
To learn how to load it from the same location as your script, see &amp;#8220;&lt;a name="XREF93954_Find_your_Scripts_Location"&gt;Find
your Script&amp;#8217;s Location&lt;/a&gt;.&amp;#8221; 
&lt;p&gt;
&lt;/p&gt;
&gt;
&lt;p class="MsoBodyText"&gt;
For more information about the &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;ConvertTo-SecureString&lt;/span&gt;&lt;/span&gt; and &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;ConvertFrom-SecureString&lt;/span&gt;&lt;/span&gt; cmdlets,
type &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;Get-Help
ConvertTo-SecureString&lt;/span&gt;&lt;/span&gt; or &lt;span class="Literal"&gt;&lt;span style="mso-bidi-font-family: &amp;#39;Times New Roman&amp;#39;"&gt;Get-Help
ConvertFrom-SecureString&lt;/span&gt;&lt;/span&gt;. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=680bc0bc-5b93-469c-8b64-be123744649b" /&gt;</description>
      <comments>http://www.leeholmes.com/blog/CommentView,guid,680bc0bc-5b93-469c-8b64-be123744649b.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.leeholmes.com/blog/Trackback.aspx?guid=9164272c-05d4-44e4-b677-58d524c85865</trackback:ping>
      <pingback:server>http://www.leeholmes.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.leeholmes.com/blog/PermaLink,guid,9164272c-05d4-44e4-b677-58d524c85865.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.leeholmes.com/blog/CommentView,guid,9164272c-05d4-44e4-b677-58d524c85865.aspx</wfw:comment>
      <wfw:commentRss>http://www.leeholmes.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=9164272c-05d4-44e4-b677-58d524c85865</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
After what seems like an eternity, I finally got to start my official flight training.
As a Canadian (AKA "Alien,") applying for flight school also means getting
your fingerprints taken and being put in a special registration system. My training
permission cleared late last week, so I booked my first lessons as soon as I could.
In fact, for a government agency, the flight registration process was surprisingly
efficient. Finding a place to get TSA-approved fingerprints outside of work hours?
Well, that's a different story. 
</p>
        <p>
Anyways. 
</p>
        <p>
One of the things I really missed about my intro flights was a good understanding
of exactly where I traveled during the flight. I remembered some landmarks, but didn't
really catch on to many streets or things I knew from my ground travels. Recording
my tracks through a GPS system seemed to be the best approach, so I finally settled
on a <a href="Lowrance Airmap 2000C">Lowrance Airmap 2000C</a>. Its features rival
most of the top-end aircraft GPS products (aside from XM weather and traffic, which
I'm not in the market for,) at a fraction of the price. For about the same cost, I
would have been able to use some computer-based GPS software on my Tablet PC, but
messing around with a Tablet PC in the cockpit seems to be a lot more trouble than
it's worth.
</p>
        <p>
          <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="clip_image001" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FlightTrainingEpisode2_13860/clip_image001_3.jpg" width="194" border="0" />
        </p>
        <p>
I took it on a long camping trip during the Memorial Day long weekend, and it was
fun watching it trace my path around the Puget Sound. It warned me plenty as I passed
through the restricted airspaces (McChord airforce base, SeaTac airport, etc,) so
luckily I wasn't actually flying. 
</p>
        <p>
On Thursday, I went for my first real lesson, flying AcuWings' Piper Warrior PA28-151.
This is the kind of plane I want to do most of my training on -- as the Cirrus SR20
(while newer and nicer) felt like it might prevent me from learning some of the subtle
basics -- like rudder control, or use of the nose-wheel while on the ground.
</p>
        <p>
          <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="188" alt="clip_image001[5]" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FlightTrainingEpisode2_13860/clip_image001%5B5%5D_1.jpg" width="244" border="0" />
        </p>
        <p>
In the introductory flights, the instructor does almost all of the ground work, aside
from giving you a brief overview of what they are doing. For your first training flight,
though, you start to take over the technical preparations: aircraft examination, engine
start procedures, pre-takeoff work, and the post-flight run-down. We spent about 45
minutes on these preparations, learning the how and why behind 80+ items in the pre-flight
and post-flight checklists. 
</p>
        <p>
In the air, we practiced straight and level flight, ascents, descents, and (level,
ascending, descending) turns. Like the flight-preparation work, non-introductory training
means that you begin to take over much more of the landing preparations. During this
flight, we did 2 landings, one being a <a href="http://en.wikipedia.org/wiki/Touch-and-go_landing">touch-and-go</a>.
For both, I flew the traffic pattern, lined up the approach, and helped guide us toward
the runway. I did a little less of the actual landing than I had done during my introductory
flights, but I think that was probably because of higher wind. This flight gave me
0.8 hours of qualified dual-instruction to apply to my flight training. 
</p>
        <p>
On Sunday, we put in another 1.1 hours of dual instruction, with the learning curve
continuing just as steep. Since I had been taught the checklists, pre-flight this
time was all my own – including the inevitable splashing of leaded, high-octane <a href="http://en.wikipedia.org/wiki/Avgas">Avgas</a> on
my hands while testing for fuel contaminants. As we prepared for takeoff, I was shown
how to talk with the tower, request permission to taxi, take-off, and practice landings.
That's a massive system of verbal cryptography that will take a while to get used
to, but you feel like part of a club when you're doing it.
</p>
        <p>
While in the air, we practiced slow flight (near-stall conditions,) stalls, and recovering
from stalls. These are the most common "emergency" situations in flight,
and are relatively easy to recover from as long as you know what you are doing. If
you haven't practiced them, then you'll just panic and donate some iron to the earth's
mantle.
</p>
        <p>
After practicing those, we started working on landings. As a skill in flying, landings
are a unique breed. They are a skill within a skill: a technique that gets lavish
attention in the context of flying, but completely independent of it. Pilots obsess
about landings the same way that cigar aficionados gush about about the tower of ash
emanating from their cigar, or how developers delight in "Perl Golf,"
</p>
        <p>
It's a journey that's just beginning -- I can't wait for more.
</p>
        <img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=9164272c-05d4-44e4-b677-58d524c85865" />
      </body>
      <title>Flight Training, Episode 2</title>
      <guid isPermaLink="false">http://www.leeholmes.com/blog/PermaLink,guid,9164272c-05d4-44e4-b677-58d524c85865.aspx</guid>
      <link>http://www.leeholmes.com/blog/FlightTrainingEpisode2.aspx</link>
      <pubDate>Wed, 04 Jun 2008 06:42:09 GMT</pubDate>
      <description>&lt;p&gt;
After what seems like an eternity, I finally got to start my official flight training.
As a Canadian (AKA &amp;quot;Alien,&amp;quot;) applying for flight school also means getting
your fingerprints taken and being put in a special registration system. My training
permission cleared late last week, so I booked my first lessons as soon as I could.
In fact, for a government agency, the flight registration process was surprisingly
efficient. Finding a place to get TSA-approved fingerprints outside of work hours?
Well, that's a different story. 
&lt;/p&gt;
&lt;p&gt;
Anyways. 
&lt;/p&gt;
&lt;p&gt;
One of the things I really missed about my intro flights was a good understanding
of exactly where I traveled during the flight. I remembered some landmarks, but didn't
really catch on to many streets or things I knew from my ground travels. Recording
my tracks through a GPS system seemed to be the best approach, so I finally settled
on a &lt;a href="Lowrance Airmap 2000C"&gt;Lowrance Airmap 2000C&lt;/a&gt;. Its features rival
most of the top-end aircraft GPS products (aside from XM weather and traffic, which
I'm not in the market for,) at a fraction of the price. For about the same cost, I
would have been able to use some computer-based GPS software on my Tablet PC, but
messing around with a Tablet PC in the cockpit seems to be a lot more trouble than
it's worth.
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="244" alt="clip_image001" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FlightTrainingEpisode2_13860/clip_image001_3.jpg" width="194" border="0" /&gt;
&lt;/p&gt;
&lt;p&gt;
I took it on a long camping trip during the Memorial Day long weekend, and it was
fun watching it trace my path around the Puget Sound. It warned me plenty as I passed
through the restricted airspaces (McChord airforce base, SeaTac airport, etc,) so
luckily I wasn't actually flying. 
&lt;/p&gt;
&lt;p&gt;
On Thursday, I went for my first real lesson, flying AcuWings' Piper Warrior PA28-151.
This is the kind of plane I want to do most of my training on -- as the Cirrus SR20
(while newer and nicer) felt like it might prevent me from learning some of the subtle
basics -- like rudder control, or use of the nose-wheel while on the ground.
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="188" alt="clip_image001[5]" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FlightTrainingEpisode2_13860/clip_image001%5B5%5D_1.jpg" width="244" border="0" /&gt;
&lt;/p&gt;
&lt;p&gt;
In the introductory flights, the instructor does almost all of the ground work, aside
from giving you a brief overview of what they are doing. For your first training flight,
though, you start to take over the technical preparations: aircraft examination, engine
start procedures, pre-takeoff work, and the post-flight run-down. We spent about 45
minutes on these preparations, learning the how and why behind 80+ items in the pre-flight
and post-flight checklists. 
&lt;/p&gt;
&lt;p&gt;
In the air, we practiced straight and level flight, ascents, descents, and (level,
ascending, descending) turns. Like the flight-preparation work, non-introductory training
means that you begin to take over much more of the landing preparations. During this
flight, we did 2 landings, one being a &lt;a href="http://en.wikipedia.org/wiki/Touch-and-go_landing"&gt;touch-and-go&lt;/a&gt;.
For both, I flew the traffic pattern, lined up the approach, and helped guide us toward
the runway. I did a little less of the actual landing than I had done during my introductory
flights, but I think that was probably because of higher wind. This flight gave me
0.8 hours of qualified dual-instruction to apply to my flight training. 
&lt;/p&gt;
&lt;p&gt;
On Sunday, we put in another 1.1 hours of dual instruction, with the learning curve
continuing just as steep. Since I had been taught the checklists, pre-flight this
time was all my own &amp;#8211; including the inevitable splashing of leaded, high-octane &lt;a href="http://en.wikipedia.org/wiki/Avgas"&gt;Avgas&lt;/a&gt; on
my hands while testing for fuel contaminants. As we prepared for takeoff, I was shown
how to talk with the tower, request permission to taxi, take-off, and practice landings.
That's a massive system of verbal cryptography that will take a while to get used
to, but you feel like part of a club when you're doing it.
&lt;/p&gt;
&lt;p&gt;
While in the air, we practiced slow flight (near-stall conditions,) stalls, and recovering
from stalls. These are the most common &amp;quot;emergency&amp;quot; situations in flight,
and are relatively easy to recover from as long as you know what you are doing. If
you haven't practiced them, then you'll just panic and donate some iron to the earth's
mantle.
&lt;/p&gt;
&lt;p&gt;
After practicing those, we started working on landings. As a skill in flying, landings
are a unique breed. They are a skill within a skill: a technique that gets lavish
attention in the context of flying, but completely independent of it. Pilots obsess
about landings the same way that cigar aficionados gush about about the tower of ash
emanating from their cigar, or how developers delight in &amp;quot;Perl Golf,&amp;quot;
&lt;/p&gt;
&lt;p&gt;
It's a journey that's just beginning -- I can't wait for more.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=9164272c-05d4-44e4-b677-58d524c85865" /&gt;</description>
      <comments>http://www.leeholmes.com/blog/CommentView,guid,9164272c-05d4-44e4-b677-58d524c85865.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.leeholmes.com/blog/Trackback.aspx?guid=43a3b5c5-b4a5-45c7-897b-abd19625c33d</trackback:ping>
      <pingback:server>http://www.leeholmes.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.leeholmes.com/blog/PermaLink,guid,43a3b5c5-b4a5-45c7-897b-abd19625c33d.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.leeholmes.com/blog/CommentView,guid,43a3b5c5-b4a5-45c7-897b-abd19625c33d.aspx</wfw:comment>
      <wfw:commentRss>http://www.leeholmes.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=43a3b5c5-b4a5-45c7-897b-abd19625c33d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Once in awhile, you'll see a PowerShell screenshot that is still black and boring
like the traditional cmd.exe prompt. Other times, you'll see the fancy blue window
you've come to love. Why the difference? And if you're suffering from black window
syndrome, what can you do about it?
</p>
        <p>
          <img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="237" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/PowerShellStillLaunchesaBlackWindow_1098D/image_6.png" width="324" border="0" />
        </p>
        <p>
Before shipping Version 1, our marketing and design teams set to make the PowerShell
window a unique and marquee experience. What form did this take?
</p>
        <ul>
          <li>
            <strong>Blue</strong>. Specifically, Red: 1, Green: 36, Blue: 86. -- In hex, 012 456.
That number is much too cool to be a coincidence, but I haven't done the social archeology
to find out why :)</li>
          <li>
            <strong>Lucida Console</strong>. Lucida Console is infinitely more readable than the
raster fonts, and ships with all versions of Windows. Consolas is a <a href="http://www.hanselman.com/blog/UsingConsolasAsTheWindowsConsoleFont.aspx">beautiful
alternative</a>, but isn't broadly available.</li>
          <li>
            <strong>Window Size</strong>. Long gone are the days of 640x480 monitors being the
most common, so PowerShell's default window gives about 800x600 of usable space.</li>
          <li>
            <strong>Screen Buffer</strong>. Likewise, long gone are the days of 256mb of memory
being the most common, so PowerShell's default window gives a dreamy 60 pages of history
buffer. This is a shell you want to live in. And when you live in a shell, you 
want to be able to see what you've done.</li>
          <li>
            <strong>Quick Edit</strong>. Quick Edit mode lets you copy and paste easily to and
from the console window. It is the setting that most console users enable once they
realize it exists, and long gone are the days of <a href="http://blogs.msdn.com/oldnewthing/archive/2007/09/13/4886108.aspx">mouse-driven
console applications</a>.</li>
        </ul>
        <p>
Now, even with all of these improvements, you still see screen shots of PowerShell
prompts blinking desolate in the confines of a traditional black console window. Why
is this?
</p>
        <p>
PowerShell customizes its window through the shortcut properties in its Start Menu
link. When you launch PowerShell through the <strong>Start | Run</strong> dialog or
some other app launcher, these shortcut properties don't apply. Surprisingly, Windows
does not support a mechanism to make these console customizations machine-wide. Windows
supports per-user console customizations in the the HKCU hive of the registry, but
there's usually no "Current User" during a PowerShell install. And even
if there were, any customizations would not apply to user accounts created after PowerShell
was installed.
</p>
        <p>
So how do you get PowerShell's Noble Blue if you prefer <strong>Start | Run</strong>?
Here's a script from the PowerShell Cookbook that does exactly that -- for your current
user account.:
</p>
        <p>
          <font face="Courier New" size="1">## From Windows PowerShell, The Definitive Guide
(O'Reilly) 
<br />
## by Lee Holmes (</font>
          <a href="http://www.leeholmes.com/guide)">
            <font face="Courier New" size="1">http://www.leeholmes.com/guide)</font>
          </a>
        </p>
        <p>
          <font face="Courier New" size="1">Push-Location 
<br />
Set-Location HKCU:\Console 
<br />
New-Item ".\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe" 
<br />
Set-Location ".\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe" </font>
        </p>
        <p>
          <font face="Courier New" size="1">New-ItemProperty . ColorTable00 -type DWORD -value
0x00562401 
<br />
New-ItemProperty . ColorTable07 -type DWORD -value 0x00f0edee 
<br />
New-ItemProperty . FaceName -type STRING -value "Lucida Console" 
<br />
New-ItemProperty . FontFamily -type DWORD -value 0x00000036 
<br />
New-ItemProperty . FontSize -type DWORD -value 0x000c0000 
<br />
New-ItemProperty . FontWeight -type DWORD -value 0x00000190 
<br />
New-ItemProperty . HistoryNoDup -type DWORD -value 0x00000000 
<br />
New-ItemProperty . QuickEdit -type DWORD -value 0x00000001 
<br />
New-ItemProperty . ScreenBufferSize -type DWORD -value 0x0bb80078 
<br />
New-ItemProperty . WindowSize -type DWORD -value 0x00320078 
<br />
Pop-Location</font>
        </p>
        <img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=43a3b5c5-b4a5-45c7-897b-abd19625c33d" />
      </body>
      <title>PowerShell's Noble Blue</title>
      <guid isPermaLink="false">http://www.leeholmes.com/blog/PermaLink,guid,43a3b5c5-b4a5-45c7-897b-abd19625c33d.aspx</guid>
      <link>http://www.leeholmes.com/blog/PowerShellsNobleBlue.aspx</link>
      <pubDate>Sun, 01 Jun 2008 03:20:24 GMT</pubDate>
      <description>&lt;p&gt;
Once in awhile, you'll see a PowerShell screenshot that is still black and boring
like the traditional cmd.exe prompt. Other times, you'll see the fancy blue window
you've come to love. Why the difference? And if you're suffering from black window
syndrome, what can you do about it?
&lt;/p&gt;
&lt;p&gt;
&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="237" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/PowerShellStillLaunchesaBlackWindow_1098D/image_6.png" width="324" border="0" /&gt; 
&lt;/p&gt;
&lt;p&gt;
Before shipping Version 1, our marketing and design teams set to make the PowerShell
window a unique and marquee experience. What form did this take?
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Blue&lt;/strong&gt;. Specifically, Red: 1, Green: 36, Blue: 86. -- In hex, 012 456.
That number is much too cool to be a coincidence, but I haven't done the social archeology
to find out why :)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Lucida Console&lt;/strong&gt;. Lucida Console is infinitely more readable than the
raster fonts, and ships with all versions of Windows. Consolas is a &lt;a href="http://www.hanselman.com/blog/UsingConsolasAsTheWindowsConsoleFont.aspx"&gt;beautiful
alternative&lt;/a&gt;, but isn't broadly available.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Window Size&lt;/strong&gt;. Long gone are the days of 640x480 monitors being the
most common, so PowerShell's default window gives about 800x600 of usable space.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Screen Buffer&lt;/strong&gt;. Likewise, long gone are the days of 256mb of memory
being the most common, so PowerShell's default window gives a dreamy 60 pages of history
buffer. This is a shell you want to live in. And when you live in a shell, you&amp;#160;
want to be able to see what you've done.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Quick Edit&lt;/strong&gt;. Quick Edit mode lets you copy and paste easily to and
from the console window. It is the setting that most console users enable once they
realize it exists, and long gone are the days of &lt;a href="http://blogs.msdn.com/oldnewthing/archive/2007/09/13/4886108.aspx"&gt;mouse-driven
console applications&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Now, even with all of these improvements, you still see screen shots of PowerShell
prompts blinking desolate in the confines of a traditional black console window. Why
is this?
&lt;/p&gt;
&lt;p&gt;
PowerShell customizes its window through the shortcut properties in its Start Menu
link. When you launch PowerShell through the &lt;strong&gt;Start | Run&lt;/strong&gt; dialog or
some other app launcher, these shortcut properties don't apply. Surprisingly, Windows
does not support a mechanism to make these console customizations machine-wide. Windows
supports per-user console customizations in the the HKCU hive of the registry, but
there's usually no &amp;quot;Current User&amp;quot; during a PowerShell install. And even
if there were, any customizations would not apply to user accounts created after PowerShell
was installed.
&lt;/p&gt;
&lt;p&gt;
So how do you get PowerShell's Noble Blue if you prefer &lt;strong&gt;Start | Run&lt;/strong&gt;?
Here's a script from the PowerShell Cookbook that does exactly that -- for your current
user account.:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" size="1"&gt;## From Windows PowerShell, The Definitive Guide
(O'Reilly) 
&lt;br /&gt;
## by Lee Holmes (&lt;/font&gt;&lt;a href="http://www.leeholmes.com/guide)"&gt;&lt;font face="Courier New" size="1"&gt;http://www.leeholmes.com/guide)&lt;/font&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" size="1"&gt;Push-Location 
&lt;br /&gt;
Set-Location HKCU:\Console 
&lt;br /&gt;
New-Item &amp;quot;.\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe&amp;quot; 
&lt;br /&gt;
Set-Location &amp;quot;.\%SystemRoot%_system32_WindowsPowerShell_v1.0_powershell.exe&amp;quot; &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New" size="1"&gt;New-ItemProperty . ColorTable00 -type DWORD -value
0x00562401 
&lt;br /&gt;
New-ItemProperty . ColorTable07 -type DWORD -value 0x00f0edee 
&lt;br /&gt;
New-ItemProperty . FaceName -type STRING -value &amp;quot;Lucida Console&amp;quot; 
&lt;br /&gt;
New-ItemProperty . FontFamily -type DWORD -value 0x00000036 
&lt;br /&gt;
New-ItemProperty . FontSize -type DWORD -value 0x000c0000 
&lt;br /&gt;
New-ItemProperty . FontWeight -type DWORD -value 0x00000190 
&lt;br /&gt;
New-ItemProperty . HistoryNoDup -type DWORD -value 0x00000000 
&lt;br /&gt;
New-ItemProperty . QuickEdit -type DWORD -value 0x00000001 
&lt;br /&gt;
New-ItemProperty . ScreenBufferSize -type DWORD -value 0x0bb80078 
&lt;br /&gt;
New-ItemProperty . WindowSize -type DWORD -value 0x00320078 
&lt;br /&gt;
Pop-Location&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=43a3b5c5-b4a5-45c7-897b-abd19625c33d" /&gt;</description>
      <comments>http://www.leeholmes.com/blog/CommentView,guid,43a3b5c5-b4a5-45c7-897b-abd19625c33d.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.leeholmes.com/blog/Trackback.aspx?guid=ccaa6171-6c86-4d91-983f-ba40feaf225a</trackback:ping>
      <pingback:server>http://www.leeholmes.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.leeholmes.com/blog/PermaLink,guid,ccaa6171-6c86-4d91-983f-ba40feaf225a.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.leeholmes.com/blog/CommentView,guid,ccaa6171-6c86-4d91-983f-ba40feaf225a.aspx</wfw:comment>
      <wfw:commentRss>http://www.leeholmes.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=ccaa6171-6c86-4d91-983f-ba40feaf225a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you're testing your PowerShell scripts (manually or automatically,) one of the
first questions you'll end up asking yourself is, "did I test enough?" 
</p>
        <p>
This is common problem in all of software development. To the rescue is a simple metric
known as "Code Coverage" – a measure of how much code you exercised
during the testing of that code. 
</p>
        <p>
However, the measurement is just the end result – you need a tool to get you
there. When it comes to measuring code coverage in PowerShell scripts, though, there
simply aren't any tools yet. 
</p>
        <p>
Like performance measurement tools, Code Coverage tools are sometimes driven by instrumentation
of the source code, and sometimes driven by sampling the code during runtime. Instrumentation
gives the highest accuracy, but we can go a long way by runtime analysis alone. To
accomplish that, we'll use our favourite feature to abuse – PowerShell script
tracing. The last time we pushed it, we got a <a href="http://www.leeholmes.com/blog/burnconsoleDigressionAnMSHScriptProfiler.aspx">sampling
profiler out of the deal</a>. Let's do it again for code coverage. 
</p>
        <p>
Take, for example, the following source code: 
</p>
        <pre style="color: #eeedf0; background-color: #012456">
          <span style="color: #cc66cc; background-color: #012456">trap</span> { <span style="color: #66cccc; background-color: #012456">"Error
handling!"</span><span style="color: #44aaaa; background-color: #012456">;</span><span style="color: #cc66cc; background-color: #012456">continue</span> } <span style="color: #66cccc; background-color: #012456">"Got
here"</span><span style="color: #cc66cc; background-color: #012456">if</span>(<span style="color: #66cc66; background-color: #012456">$args</span><span style="color: #44aaaa; background-color: #012456">[</span><span style="color: #66cccc; background-color: #012456">0</span><span style="color: #44aaaa; background-color: #012456">]</span><span style="color: #44aaaa; background-color: #012456">-eq</span><span style="color: #66cccc; background-color: #012456">"Test"</span>)
{ <span style="color: #66cccc; background-color: #012456">"Got TEST as an argument"</span> } <span style="color: #cc66cc; background-color: #012456">elseif</span>(<span style="color: #66cc66; background-color: #012456">$args</span><span style="color: #44aaaa; background-color: #012456">[</span><span style="color: #66cccc; background-color: #012456">0</span><span style="color: #44aaaa; background-color: #012456">]</span><span style="color: #44aaaa; background-color: #012456">-eq</span><span style="color: #66cccc; background-color: #012456">"Err0r"</span>)
{ <span style="color: #cc66cc; background-color: #012456">throw</span><span style="color: #66cccc; background-color: #012456">"Catch
Me!"</span> } <span style="color: #cc66cc; background-color: #012456">else</span> { <span style="color: #66cccc; background-color: #012456">"Didn't
get TEST as an argument"</span> } </pre>
        <p>
We want to run through three parameters that it takes, and make sure we're exercising
everything. Notice how we're even being diligent by testing the "Error"
case! 
</p>
        <pre style="color: #eeedf0; background-color: #012456">PS C:\temp&gt; $tests = @()                                              
PS C:\temp&gt; $tests += { .\Test-CodeCoverage.ps1 Test }                
PS C:\temp&gt; $tests += { .\Test-CodeCoverage.ps1 SomethingElse }       
PS C:\temp&gt; $tests += { .\Test-CodeCoverage.ps1 Error }               
PS C:\temp&gt;                                                           
PS C:\temp&gt; .\Get-ScriptCoverage.ps1 .\Test-CodeCoverage.ps1 $tests </pre>
        <p>
What does that give us? 
</p>
        <pre style="color: #eeedf0; background-color: #012456">
          <span style="color: #cc6666; background-color: #012456">trap
{ "Error handling!"; continue }</span>
          <span style="color: #66cc66; background-color: #012456">"Got
here"</span>
          <span style="color: #66cc66; background-color: #012456">if($args[0]
-eq "Test")</span> { <span style="color: #66cc66; background-color: #012456"> "Got
TEST as an argument"</span> } elseif($args[0] -eq "Err0r") { <span style="color: #cc6666; background-color: #012456"> throw
"Catch Me!"</span> } else { <span style="color: #66cc66; background-color: #012456"> "Didn't
get TEST as an argument"</span> } Coverage Statistics: 66.6666666666667% PS C:\temp&gt; </pre>
        <p>
Ouch! Why is the error handling code (in red) not being hit? Ah, after further investigation,
it turns out that we have a typo in our string comparison. We fix it: 
</p>
        <blockquote>
          <p>
... 
<br />
elseif($args[0] -eq "Err<font color="#ff0000">0</font>r") 
<br />
... 
</p>
        </blockquote>
        <p>
Becomes 
</p>
        <blockquote>
          <p>
... 
<br />
elseif($args[0] -eq "Error") 
<br />
... 
</p>
        </blockquote>
        <p>
And run code coverage again: 
</p>
        <pre style="color: #eeedf0; background-color: #012456">
          <span style="color: #66cc66; background-color: #012456">trap
{ "Error handling!"; continue }</span>
          <span style="color: #66cc66; background-color: #012456">"Got
here"</span>
          <span style="color: #66cc66; background-color: #012456">if($args[0]
-eq "Test")</span> { <span style="color: #66cc66; background-color: #012456"> "Got
TEST as an argument"</span> } elseif($args[0] -eq "Error") { <span style="color: #66cc66; background-color: #012456"> throw
"Catch Me!"</span> } else { <span style="color: #66cc66; background-color: #012456"> "Didn't
get TEST as an argument"</span> } Coverage Statistics: 100% PS C:\temp&gt; </pre>
        <p>
Much better. 
</p>
        <p>
Here is the script – under 80 lines of (heavily commented) code: 
</p>
        <pre style="color: #eeedf0; background-color: #012456">
          <span style="color: #cc6666; background-color: #012456">##
Get-ScriptCoverage.ps1</span>
          <span style="color: #cc6666; background-color: #012456">##
Test the script named by $testScript for code coverage.</span>
          <span style="color: #cc6666; background-color: #012456">##
The command given by $command must exercise this named</span>
          <span style="color: #cc6666; background-color: #012456">##
script.</span>
          <span style="color: #cc66cc; background-color: #012456">param</span>(<span style="color: #aaaa44; background-color: #012456">[string]</span><span style="color: #66cc66; background-color: #012456">$testScript</span><span style="color: #44aaaa; background-color: #012456">,</span><span style="color: #aaaa44; background-color: #012456">[ScriptBlock[]]</span><span style="color: #66cc66; background-color: #012456">$command</span>) <span style="color: #cc6666; background-color: #012456">#
Store the content of the script to be tested</span><span style="color: #66cc66; background-color: #012456">$fileContent</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #cccc66; background-color: #012456">gc</span><span style="color: #66cc66; background-color: #012456">$testScript</span><span style="color: #cccc66; background-color: #012456">-ea</span><span style="color: #66cccc; background-color: #012456">Stop</span><span style="color: #cc6666; background-color: #012456">##
Start a transcript, and log it to a file</span><span style="color: #66cc66; background-color: #012456">$tempFile</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #aaaa44; background-color: #012456">[IO.Path]</span><span style="color: #44aaaa; background-color: #012456">::</span><span style="color: #aaaa44; background-color: #012456">GetTempFilename</span>() <span style="color: #cccc66; background-color: #012456">Start-Transcript</span><span style="color: #66cc66; background-color: #012456">$tempFile</span><span style="color: #cc6666; background-color: #012456">##
Turn on line-level tracing, run the command(s),</span><span style="color: #cc6666; background-color: #012456">##
then turn off line-level tracing again.</span><span style="color: #cccc66; background-color: #012456">Set-PsDebug</span><span style="color: #cccc66; background-color: #012456">-Trace</span><span style="color: #66cccc; background-color: #012456">1</span><span style="color: #66cc66; background-color: #012456">$command</span><span style="color: #44aaaa; background-color: #012456">|</span><span style="color: #cccc66; background-color: #012456">Foreach-Object</span> { <span style="color: #44aaaa; background-color: #012456">&amp;</span><span style="color: #66cc66; background-color: #012456">$_</span> } <span style="color: #cccc66; background-color: #012456">Set-PsDebug</span><span style="color: #cccc66; background-color: #012456">-Trace</span><span style="color: #66cccc; background-color: #012456">0</span><span style="color: #cc6666; background-color: #012456">##
Stop the transcript</span><span style="color: #cccc66; background-color: #012456">Stop-Transcript</span><span style="color: #cc6666; background-color: #012456">##
Get the result of the script coverage run</span><span style="color: #66cc66; background-color: #012456">$coverageContent</span><span style="color: #44aaaa; background-color: #012456">=</span> (<span style="color: #cccc66; background-color: #012456">gc</span><span style="color: #66cc66; background-color: #012456">$tempFile</span>) <span style="color: #44aaaa; background-color: #012456">-match</span><span style="color: #66cccc; background-color: #012456">"^DEBUG:"</span><span style="color: #cccc66; background-color: #012456">Remove-Item</span><span style="color: #cccc66; background-color: #012456">-LiteralPath</span><span style="color: #66cc66; background-color: #012456">$tempFile</span><span style="color: #cccc66; background-color: #012456">Clear-Host</span><span style="color: #cc6666; background-color: #012456">##
Clean up interference from other scripts</span><span style="color: #66cc66; background-color: #012456">$scriptLines</span><span style="color: #44aaaa; background-color: #012456">=</span> @() <span style="color: #66cc66; background-color: #012456">$processedLines</span><span style="color: #44aaaa; background-color: #012456">=</span> @{} <span style="color: #cc66cc; background-color: #012456">foreach</span>(<span style="color: #66cc66; background-color: #012456">$originalLine</span><span style="color: #cc66cc; background-color: #012456">in</span><span style="color: #66cc66; background-color: #012456">$coverageContent</span>)
{ <span style="color: #cc6666; background-color: #012456"># Make sure we only process
unique lines in the</span><span style="color: #cc6666; background-color: #012456">#
transcript</span><span style="color: #cc66cc; background-color: #012456">if</span>(<span style="color: #66cc66; background-color: #012456">$processedLines</span><span style="color: #44aaaa; background-color: #012456">[</span><span style="color: #66cc66; background-color: #012456">$originalLine</span><span style="color: #44aaaa; background-color: #012456">]</span>)
{ <span style="color: #cc66cc; background-color: #012456">continue</span> } <span style="color: #66cc66; background-color: #012456">$processedLines</span><span style="color: #44aaaa; background-color: #012456">[</span><span style="color: #66cc66; background-color: #012456">$originalLine</span><span style="color: #44aaaa; background-color: #012456">]</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cc66; background-color: #012456">$true</span><span style="color: #cc6666; background-color: #012456">##
Recover as much as possible from the original script line</span><span style="color: #cc6666; background-color: #012456">##
without its debugging information</span><span style="color: #66cc66; background-color: #012456">$originalLine</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cc66; background-color: #012456">$originalLine</span><span style="color: #44aaaa; background-color: #012456">-replace</span><span style="color: #66cccc; background-color: #012456">" <span>&lt;</span><span>&lt;</span><span>&lt;</span><span>&lt;</span> "</span><span style="color: #44aaaa; background-color: #012456">,</span><span style="color: #66cccc; background-color: #012456">""</span><span style="color: #66cc66; background-color: #012456">$line</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cc66; background-color: #012456">$originalLine</span><span style="color: #44aaaa; background-color: #012456">-replace</span><span style="color: #66cccc; background-color: #012456">'\D*\d+\+
(.*)'</span><span style="color: #44aaaa; background-color: #012456">,</span><span style="color: #66cccc; background-color: #012456">'$1'</span><span style="color: #cc6666; background-color: #012456">##
Go through each line in the original script, and see if</span><span style="color: #cc6666; background-color: #012456">##
this is actually in the script</span><span style="color: #cc66cc; background-color: #012456">foreach</span>(<span style="color: #66cc66; background-color: #012456">$fileLine</span><span style="color: #cc66cc; background-color: #012456">in</span><span style="color: #66cc66; background-color: #012456">$fileContent</span>)
{ <span style="color: #cc6666; background-color: #012456">## If it is, add the debug
line to the list of lines</span><span style="color: #cc6666; background-color: #012456">##
covered by this scenario</span><span style="color: #cc66cc; background-color: #012456">if</span>(<span style="color: #66cc66; background-color: #012456">$fileLine</span><span style="color: #44aaaa; background-color: #012456">.</span><span style="color: #aaaa44; background-color: #012456">Contains</span>(<span style="color: #66cc66; background-color: #012456">$line</span>))
{ <span style="color: #66cc66; background-color: #012456">$scriptLines</span><span style="color: #44aaaa; background-color: #012456">+=</span><span style="color: #66cc66; background-color: #012456">$originalLine</span> }
} } <span style="color: #cc6666; background-color: #012456">## Find out which line
numbers were covered</span><span style="color: #66cc66; background-color: #012456">$coveredLines</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cc66; background-color: #012456">$scriptLines</span><span style="color: #44aaaa; background-color: #012456">|</span><span style="color: #cccc66; background-color: #012456">%</span> { <span style="color: #66cc66; background-color: #012456">$_</span><span style="color: #44aaaa; background-color: #012456">-replace</span><span style="color: #66cccc; background-color: #012456">'\D*(\d+)\+
.*'</span><span style="color: #44aaaa; background-color: #012456">,</span><span style="color: #66cccc; background-color: #012456">'$1'</span> } <span style="color: #44aaaa; background-color: #012456">|</span><span style="color: #cccc66; background-color: #012456">Sort</span><span style="color: #cccc66; background-color: #012456">-Unique</span><span style="color: #66cc66; background-color: #012456">$coverageCount</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cccc; background-color: #012456">0</span><span style="color: #66cc66; background-color: #012456">$possibleCoveredLines</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cccc; background-color: #012456">0</span><span style="color: #cc66cc; background-color: #012456">for</span>(<span style="color: #66cc66; background-color: #012456">$counter</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cccc; background-color: #012456">1</span><span style="color: #44aaaa; background-color: #012456">;</span><span style="color: #66cc66; background-color: #012456">$counter</span><span style="color: #44aaaa; background-color: #012456">-le</span><span style="color: #66cc66; background-color: #012456">$fileContent</span><span style="color: #44aaaa; background-color: #012456">.</span><span style="color: #aaaa44; background-color: #012456">Count</span><span style="color: #44aaaa; background-color: #012456">;</span><span style="color: #66cc66; background-color: #012456">$counter</span><span style="color: #44aaaa; background-color: #012456">++</span>)
{ <span style="color: #66cc66; background-color: #012456">$color</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cccc; background-color: #012456">"Red"</span><span style="color: #66cc66; background-color: #012456">$line</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cc66; background-color: #012456">$fileContent</span><span style="color: #44aaaa; background-color: #012456">[</span><span style="color: #66cc66; background-color: #012456">$counter</span><span style="color: #44aaaa; background-color: #012456">-</span><span style="color: #66cccc; background-color: #012456">1</span><span style="color: #44aaaa; background-color: #012456">]</span><span style="color: #cc6666; background-color: #012456">##
Ignore comments, blank lines, curly</span><span style="color: #cc6666; background-color: #012456">##
braces, and fall-through conditional statements</span><span style="color: #cc6666; background-color: #012456">##
in coverage computation (as they are never</span><span style="color: #cc6666; background-color: #012456">##
traced in Set-PsDebug tracing</span><span style="color: #cc66cc; background-color: #012456">if</span>((<span style="color: #66cc66; background-color: #012456">$line</span><span style="color: #44aaaa; background-color: #012456">-notmatch</span><span style="color: #66cccc; background-color: #012456">'^\s*#'</span>) <span style="color: #44aaaa; background-color: #012456">-and</span> (<span style="color: #66cc66; background-color: #012456">$line</span><span style="color: #44aaaa; background-color: #012456">-notmatch</span><span style="color: #66cccc; background-color: #012456">'^\s*{\s*$'</span>) <span style="color: #44aaaa; background-color: #012456">-and</span> (<span style="color: #66cc66; background-color: #012456">$line</span><span style="color: #44aaaa; background-color: #012456">-notmatch</span><span style="color: #66cccc; background-color: #012456">'^\s*}\s*$'</span>) <span style="color: #44aaaa; background-color: #012456">-and</span> (<span style="color: #66cc66; background-color: #012456">$line</span><span style="color: #44aaaa; background-color: #012456">-notmatch</span><span style="color: #66cccc; background-color: #012456">'^\s*else'</span>) <span style="color: #44aaaa; background-color: #012456">-and</span> (<span style="color: #66cc66; background-color: #012456">$line</span><span style="color: #44aaaa; background-color: #012456">-notmatch</span><span style="color: #66cccc; background-color: #012456">'^\s*param\('</span>) <span style="color: #44aaaa; background-color: #012456">-and</span> (<span style="color: #66cc66; background-color: #012456">$line</span><span style="color: #44aaaa; background-color: #012456">.</span><span style="color: #aaaa44; background-color: #012456">Trim</span>()))
{ <span style="color: #66cc66; background-color: #012456">$possibleCoveredLines</span><span style="color: #44aaaa; background-color: #012456">++</span> } <span style="color: #cc66cc; background-color: #012456">else</span> { <span style="color: #66cc66; background-color: #012456">$color</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cccc; background-color: #012456">"Gray"</span> } <span style="color: #cc6666; background-color: #012456">##
If this line was hit in code coverage, colour it</span><span style="color: #cc6666; background-color: #012456">##
green</span><span style="color: #cc66cc; background-color: #012456">if</span>(<span style="color: #66cc66; background-color: #012456">$coveredLines</span><span style="color: #44aaaa; background-color: #012456">-contains</span><span style="color: #66cc66; background-color: #012456">$counter</span>)
{ <span style="color: #66cc66; background-color: #012456">$color</span><span style="color: #44aaaa; background-color: #012456">=</span><span style="color: #66cccc; background-color: #012456">"Green"</span><span style="color: #66cc66; background-color: #012456">$coverageCount</span><span style="color: #44aaaa; background-color: #012456">++</span> } <span style="color: #cc6666; background-color: #012456">##
Display the line in the appropriate colour</span><span style="color: #cccc66; background-color: #012456">Write-Host</span><span style="color: #cccc66; background-color: #012456">-Fore</span><span style="color: #66cc66; background-color: #012456">$color</span><span style="color: #66cc66; background-color: #012456">$line</span> } <span style="color: #cc6666; background-color: #012456">##
Output the coverage statistics</span><span style="color: #cccc66; background-color: #012456">Write-Host</span> (<span style="color: #66cccc; background-color: #012456">"Coverage
Statistics: "</span><span style="color: #44aaaa; background-color: #012456">+</span><span style="color: #66cccc; background-color: #012456">"$($coverageCount
/ $possibleCoveredLines * 100)%"</span>) </pre>
        <img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=ccaa6171-6c86-4d91-983f-ba40feaf225a" />
      </body>
      <title>Generating Code Coverage from PowerShell Scripts</title>
      <guid isPermaLink="false">http://www.leeholmes.com/blog/PermaLink,guid,ccaa6171-6c86-4d91-983f-ba40feaf225a.aspx</guid>
      <link>http://www.leeholmes.com/blog/GeneratingCodeCoverageFromPowerShellScripts.aspx</link>
      <pubDate>Tue, 20 May 2008 07:47:31 GMT</pubDate>
      <description>&lt;p&gt;
If you're testing your PowerShell scripts (manually or automatically,) one of the
first questions you'll end up asking yourself is, &amp;quot;did I test enough?&amp;quot; 
&lt;/p&gt;
&lt;p&gt;
This is common problem in all of software development. To the rescue is a simple metric
known as &amp;quot;Code Coverage&amp;quot; &amp;#8211; a measure of how much code you exercised
during the testing of that code. 
&lt;/p&gt;
&lt;p&gt;
However, the measurement is just the end result &amp;#8211; you need a tool to get you
there. When it comes to measuring code coverage in PowerShell scripts, though, there
simply aren't any tools yet. 
&lt;/p&gt;
&lt;p&gt;
Like performance measurement tools, Code Coverage tools are sometimes driven by instrumentation
of the source code, and sometimes driven by sampling the code during runtime. Instrumentation
gives the highest accuracy, but we can go a long way by runtime analysis alone. To
accomplish that, we'll use our favourite feature to abuse &amp;#8211; PowerShell script
tracing. The last time we pushed it, we got a &lt;a href="http://www.leeholmes.com/blog/burnconsoleDigressionAnMSHScriptProfiler.aspx"&gt;sampling
profiler out of the deal&lt;/a&gt;. Let's do it again for code coverage. 
&lt;/p&gt;
&lt;p&gt;
Take, for example, the following source code: 
&lt;/p&gt;
&lt;pre style="color: #eeedf0; background-color: #012456"&gt;&lt;span style="color: #cc66cc; background-color: #012456"&gt;trap&lt;/span&gt; { &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Error
handling!&amp;quot;&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;;&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;continue&lt;/span&gt; } &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Got
here&amp;quot;&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;if&lt;/span&gt;(&lt;span style="color: #66cc66; background-color: #012456"&gt;$args&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;[&lt;/span&gt;&lt;span style="color: #66cccc; background-color: #012456"&gt;0&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;]&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-eq&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Test&amp;quot;&lt;/span&gt;)
{ &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Got TEST as an argument&amp;quot;&lt;/span&gt; } &lt;span style="color: #cc66cc; background-color: #012456"&gt;elseif&lt;/span&gt;(&lt;span style="color: #66cc66; background-color: #012456"&gt;$args&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;[&lt;/span&gt;&lt;span style="color: #66cccc; background-color: #012456"&gt;0&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;]&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-eq&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Err0r&amp;quot;&lt;/span&gt;)
{ &lt;span style="color: #cc66cc; background-color: #012456"&gt;throw&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Catch
Me!&amp;quot;&lt;/span&gt; } &lt;span style="color: #cc66cc; background-color: #012456"&gt;else&lt;/span&gt; { &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Didn't
get TEST as an argument&amp;quot;&lt;/span&gt; } &lt;/pre&gt;
&lt;p&gt;
We want to run through three parameters that it takes, and make sure we're exercising
everything. Notice how we're even being diligent by testing the &amp;quot;Error&amp;quot;
case! 
&lt;/p&gt;
&lt;pre style="color: #eeedf0; background-color: #012456"&gt;PS C:\temp&amp;gt; $tests = @()                                              
PS C:\temp&amp;gt; $tests += { .\Test-CodeCoverage.ps1 Test }                
PS C:\temp&amp;gt; $tests += { .\Test-CodeCoverage.ps1 SomethingElse }       
PS C:\temp&amp;gt; $tests += { .\Test-CodeCoverage.ps1 Error }               
PS C:\temp&amp;gt;                                                           
PS C:\temp&amp;gt; .\Get-ScriptCoverage.ps1 .\Test-CodeCoverage.ps1 $tests &lt;/pre&gt;
&lt;p&gt;
What does that give us? 
&lt;/p&gt;
&lt;pre style="color: #eeedf0; background-color: #012456"&gt;&lt;span style="color: #cc6666; background-color: #012456"&gt;trap
{ &amp;quot;Error handling!&amp;quot;; continue }&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;&amp;quot;Got
here&amp;quot;&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;if($args[0]
-eq &amp;quot;Test&amp;quot;)&lt;/span&gt; { &lt;span style="color: #66cc66; background-color: #012456"&gt; &amp;quot;Got
TEST as an argument&amp;quot;&lt;/span&gt; } elseif($args[0] -eq &amp;quot;Err0r&amp;quot;) { &lt;span style="color: #cc6666; background-color: #012456"&gt; throw
&amp;quot;Catch Me!&amp;quot;&lt;/span&gt; } else { &lt;span style="color: #66cc66; background-color: #012456"&gt; &amp;quot;Didn't
get TEST as an argument&amp;quot;&lt;/span&gt; } Coverage Statistics: 66.6666666666667% PS C:\temp&amp;gt; &lt;/pre&gt;
&lt;p&gt;
Ouch! Why is the error handling code (in red) not being hit? Ah, after further investigation,
it turns out that we have a typo in our string comparison. We fix it: 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
... 
&lt;br /&gt;
elseif($args[0] -eq &amp;quot;Err&lt;font color="#ff0000"&gt;0&lt;/font&gt;r&amp;quot;) 
&lt;br /&gt;
... 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Becomes 
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
... 
&lt;br /&gt;
elseif($args[0] -eq &amp;quot;Error&amp;quot;) 
&lt;br /&gt;
... 
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
And run code coverage again: 
&lt;/p&gt;
&lt;pre style="color: #eeedf0; background-color: #012456"&gt;&lt;span style="color: #66cc66; background-color: #012456"&gt;trap
{ &amp;quot;Error handling!&amp;quot;; continue }&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;&amp;quot;Got
here&amp;quot;&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;if($args[0]
-eq &amp;quot;Test&amp;quot;)&lt;/span&gt; { &lt;span style="color: #66cc66; background-color: #012456"&gt; &amp;quot;Got
TEST as an argument&amp;quot;&lt;/span&gt; } elseif($args[0] -eq &amp;quot;Error&amp;quot;) { &lt;span style="color: #66cc66; background-color: #012456"&gt; throw
&amp;quot;Catch Me!&amp;quot;&lt;/span&gt; } else { &lt;span style="color: #66cc66; background-color: #012456"&gt; &amp;quot;Didn't
get TEST as an argument&amp;quot;&lt;/span&gt; } Coverage Statistics: 100% PS C:\temp&amp;gt; &lt;/pre&gt;
&lt;p&gt;
Much better. 
&lt;/p&gt;
&lt;p&gt;
Here is the script &amp;#8211; under 80 lines of (heavily commented) code: 
&lt;/p&gt;
&lt;pre style="color: #eeedf0; background-color: #012456"&gt;&lt;span style="color: #cc6666; background-color: #012456"&gt;##
Get-ScriptCoverage.ps1&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Test the script named by $testScript for code coverage.&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
The command given by $command must exercise this named&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
script.&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;param&lt;/span&gt;(&lt;span style="color: #aaaa44; background-color: #012456"&gt;[string]&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$testScript&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;,&lt;/span&gt; &lt;span style="color: #aaaa44; background-color: #012456"&gt;[ScriptBlock[]]&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$command&lt;/span&gt;) &lt;span style="color: #cc6666; background-color: #012456"&gt;#
Store the content of the script to be tested&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$fileContent&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;gc&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$testScript&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;-ea&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;Stop&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Start a transcript, and log it to a file&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$tempFile&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #aaaa44; background-color: #012456"&gt;[IO.Path]&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;::&lt;/span&gt;&lt;span style="color: #aaaa44; background-color: #012456"&gt;GetTempFilename&lt;/span&gt;() &lt;span style="color: #cccc66; background-color: #012456"&gt;Start-Transcript&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$tempFile&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Turn on line-level tracing, run the command(s),&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
then turn off line-level tracing again.&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;Set-PsDebug&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;-Trace&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;1&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$command&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;|&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;Foreach-Object&lt;/span&gt; { &lt;span style="color: #44aaaa; background-color: #012456"&gt;&amp;amp;&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$_&lt;/span&gt; } &lt;span style="color: #cccc66; background-color: #012456"&gt;Set-PsDebug&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;-Trace&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;0&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Stop the transcript&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;Stop-Transcript&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Get the result of the script coverage run&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$coverageContent&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; (&lt;span style="color: #cccc66; background-color: #012456"&gt;gc&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$tempFile&lt;/span&gt;) &lt;span style="color: #44aaaa; background-color: #012456"&gt;-match&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;^DEBUG:&amp;quot;&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;Remove-Item&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;-LiteralPath&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$tempFile&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;Clear-Host&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Clean up interference from other scripts&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$scriptLines&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; @() &lt;span style="color: #66cc66; background-color: #012456"&gt;$processedLines&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; @{} &lt;span style="color: #cc66cc; background-color: #012456"&gt;foreach&lt;/span&gt;(&lt;span style="color: #66cc66; background-color: #012456"&gt;$originalLine&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;in&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$coverageContent&lt;/span&gt;)
{ &lt;span style="color: #cc6666; background-color: #012456"&gt;# Make sure we only process
unique lines in the&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;#
transcript&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;if&lt;/span&gt;(&lt;span style="color: #66cc66; background-color: #012456"&gt;$processedLines&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;[&lt;/span&gt;&lt;span style="color: #66cc66; background-color: #012456"&gt;$originalLine&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;]&lt;/span&gt;)
{ &lt;span style="color: #cc66cc; background-color: #012456"&gt;continue&lt;/span&gt; } &lt;span style="color: #66cc66; background-color: #012456"&gt;$processedLines&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;[&lt;/span&gt;&lt;span style="color: #66cc66; background-color: #012456"&gt;$originalLine&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;]&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$true&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Recover as much as possible from the original script line&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
without its debugging information&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$originalLine&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$originalLine&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-replace&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot; &lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt;&lt;span&gt;&amp;lt;&lt;/span&gt; &amp;quot;&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;,&lt;/span&gt;&lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;&amp;quot;&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$originalLine&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-replace&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;'\D*\d+\+
(.*)'&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;,&lt;/span&gt;&lt;span style="color: #66cccc; background-color: #012456"&gt;'$1'&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Go through each line in the original script, and see if&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
this is actually in the script&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;foreach&lt;/span&gt;(&lt;span style="color: #66cc66; background-color: #012456"&gt;$fileLine&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;in&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$fileContent&lt;/span&gt;)
{ &lt;span style="color: #cc6666; background-color: #012456"&gt;## If it is, add the debug
line to the list of lines&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
covered by this scenario&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;if&lt;/span&gt;(&lt;span style="color: #66cc66; background-color: #012456"&gt;$fileLine&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;.&lt;/span&gt;&lt;span style="color: #aaaa44; background-color: #012456"&gt;Contains&lt;/span&gt;(&lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt;))
{ &lt;span style="color: #66cc66; background-color: #012456"&gt;$scriptLines&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;+=&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$originalLine&lt;/span&gt; }
} } &lt;span style="color: #cc6666; background-color: #012456"&gt;## Find out which line
numbers were covered&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$coveredLines&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$scriptLines&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;|&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;%&lt;/span&gt; { &lt;span style="color: #66cc66; background-color: #012456"&gt;$_&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-replace&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;'\D*(\d+)\+
.*'&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;,&lt;/span&gt;&lt;span style="color: #66cccc; background-color: #012456"&gt;'$1'&lt;/span&gt; } &lt;span style="color: #44aaaa; background-color: #012456"&gt;|&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;Sort&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;-Unique&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$coverageCount&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;0&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$possibleCoveredLines&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;0&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;for&lt;/span&gt;(&lt;span style="color: #66cc66; background-color: #012456"&gt;$counter&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;1&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;;&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$counter&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-le&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$fileContent&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;.&lt;/span&gt;&lt;span style="color: #aaaa44; background-color: #012456"&gt;Count&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;;&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$counter&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;++&lt;/span&gt;)
{ &lt;span style="color: #66cc66; background-color: #012456"&gt;$color&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Red&amp;quot;&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$fileContent&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;[&lt;/span&gt;&lt;span style="color: #66cc66; background-color: #012456"&gt;$counter&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;1&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;]&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Ignore comments, blank lines, curly&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
braces, and fall-through conditional statements&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
in coverage computation (as they are never&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
traced in Set-PsDebug tracing&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;if&lt;/span&gt;((&lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-notmatch&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;'^\s*#'&lt;/span&gt;) &lt;span style="color: #44aaaa; background-color: #012456"&gt;-and&lt;/span&gt; (&lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-notmatch&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;'^\s*{\s*$'&lt;/span&gt;) &lt;span style="color: #44aaaa; background-color: #012456"&gt;-and&lt;/span&gt; (&lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-notmatch&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;'^\s*}\s*$'&lt;/span&gt;) &lt;span style="color: #44aaaa; background-color: #012456"&gt;-and&lt;/span&gt; (&lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-notmatch&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;'^\s*else'&lt;/span&gt;) &lt;span style="color: #44aaaa; background-color: #012456"&gt;-and&lt;/span&gt; (&lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-notmatch&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;'^\s*param\('&lt;/span&gt;) &lt;span style="color: #44aaaa; background-color: #012456"&gt;-and&lt;/span&gt; (&lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;.&lt;/span&gt;&lt;span style="color: #aaaa44; background-color: #012456"&gt;Trim&lt;/span&gt;()))
{ &lt;span style="color: #66cc66; background-color: #012456"&gt;$possibleCoveredLines&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;++&lt;/span&gt; } &lt;span style="color: #cc66cc; background-color: #012456"&gt;else&lt;/span&gt; { &lt;span style="color: #66cc66; background-color: #012456"&gt;$color&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Gray&amp;quot;&lt;/span&gt; } &lt;span style="color: #cc6666; background-color: #012456"&gt;##
If this line was hit in code coverage, colour it&lt;/span&gt; &lt;span style="color: #cc6666; background-color: #012456"&gt;##
green&lt;/span&gt; &lt;span style="color: #cc66cc; background-color: #012456"&gt;if&lt;/span&gt;(&lt;span style="color: #66cc66; background-color: #012456"&gt;$coveredLines&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;-contains&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$counter&lt;/span&gt;)
{ &lt;span style="color: #66cc66; background-color: #012456"&gt;$color&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;=&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Green&amp;quot;&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$coverageCount&lt;/span&gt;&lt;span style="color: #44aaaa; background-color: #012456"&gt;++&lt;/span&gt; } &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Display the line in the appropriate colour&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;Write-Host&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;-Fore&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$color&lt;/span&gt; &lt;span style="color: #66cc66; background-color: #012456"&gt;$line&lt;/span&gt; } &lt;span style="color: #cc6666; background-color: #012456"&gt;##
Output the coverage statistics&lt;/span&gt; &lt;span style="color: #cccc66; background-color: #012456"&gt;Write-Host&lt;/span&gt; (&lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;Coverage
Statistics: &amp;quot;&lt;/span&gt; &lt;span style="color: #44aaaa; background-color: #012456"&gt;+&lt;/span&gt; &lt;span style="color: #66cccc; background-color: #012456"&gt;&amp;quot;$($coverageCount
/ $possibleCoveredLines * 100)%&amp;quot;&lt;/span&gt;) &lt;/pre&gt;
&lt;img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=ccaa6171-6c86-4d91-983f-ba40feaf225a" /&gt;</description>
      <comments>http://www.leeholmes.com/blog/CommentView,guid,ccaa6171-6c86-4d91-983f-ba40feaf225a.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://www.leeholmes.com/blog/Trackback.aspx?guid=b605a295-8e9a-4774-b529-06c4a73327ce</trackback:ping>
      <pingback:server>http://www.leeholmes.com/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.leeholmes.com/blog/PermaLink,guid,b605a295-8e9a-4774-b529-06c4a73327ce.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://www.leeholmes.com/blog/CommentView,guid,b605a295-8e9a-4774-b529-06c4a73327ce.aspx</wfw:comment>
      <wfw:commentRss>http://www.leeholmes.com/blog/SyndicationService.asmx/GetEntryCommentsRss?guid=b605a295-8e9a-4774-b529-06c4a73327ce</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
For a long time, I've been thinking about learning to fly. One of the random long-distance-drive
conversations I like to have is, "What job would you do if you were for some reason
prevented from doing what you do now?" For me, flying has always been something I
would entertain, but only romantically. The downsides to doing it professionally are
huge -- the time away from your family and strict seniority-based promotions being
the two largest factors. So instead, I wanted to reward myself with flying lessons
the next time I thought it was appropriate. A King of the Hill episode, of all things,
changed my mind on that. 
</p>
        <p align="center">
          <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="226" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstStepsinFlight_8B3E/image_3.png" width="204" border="0" />
        </p>
        <p>
In that episode, Hank (the father) and Peggy (the mother) were going through marital
problems, and spoke with a counselor. The counselor asked them what they wanted to
do when they retired -- something they had been planning toward for a long time. Their
dream was to buy some motorcycles and tour the United States together. The counselor's
suggestion was simple -- holding off on buying the bikes doesn't really help anything,
so just buy the darn things and start enjoying yourselves! The cross-country tours
can wait until you have the time to do them, but little local trips can happen right
now. 
</p>
        <p>
That started the slow chemical reaction in my brain, which ultimately led me to start
investigating flying lessons more seriously. 
</p>
        <p>
My typical obsessive online research turned up lots of information about learning
to fly. Tom Unger’s “<a href="http://www.tumtum.com/flight/lessons/FlightLesson_1.shtml">Flying
Lessons</a>” journal was indispensable, gave a lot of great background information,
and what to expect with the process. However, I found very little about picking a
flight school around the Seattle area, and sent a mail to an internal mailing list
asking for opinions. Four suggestions came up most frequently:
</p>
        <ul>
          <li>
Pro-Flight Aviation: <a href="http://www.flyproflight.com/">http://www.flyproflight.com/</a></li>
          <li>
Galvin Flying Service: <a href="http://www.galvinflying.com/">http://www.galvinflying.com/</a></li>
          <li>
Acu-Wings: <a href="http://www.acuwings.com/">http://www.acuwings.com/</a></li>
          <li>
Alternate Air: <a href="http://www.alternateair.com/">http://www.alternateair.com/</a></li>
        </ul>
        <p>
I ruled out Galvin immediately – their responses to customer complaints on <a href="http://www.airnav.com/airport/KBFI/GALVIN">http://www.airnav.com/airport/KBFI/GALVIN</a> were
ridiculous and showed complete disregard for their customers. 
</p>
        <p>
I ended up looking for operations out of the Renton Municipal Airport (KRNT) as my
primary factor. It’s close to my house, and commute time seems to be the most important
element in choosing a base. Airport traffic and other factors can be learned at other
airports (such as Crest Airpark for its crazy small field, and Boeing Field for its
busy airspace,) since most of your practice take-offs and landings come from explicit
training exercises (as opposed to being dictated by the base you fly from.)
</p>
        <p>
I first checked out Pro-Flight during a 9:00 AM intro flight, taking up a well-loved
Cessna 172. Introductory flights are an amazing deal – even as a leisure activity.
They cost under $100 for a scenic tour of the Puget Sound, and you get to do most
of the flying yourself. 
</p>
        <p align="center">
          <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="191" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstStepsinFlight_8B3E/image_6.png" width="234" border="0" />        <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="191" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstStepsinFlight_8B3E/image_9.png" width="234" border="0" /></p>
        <p>
The biggest challenge (as compared to driving a car) was adapting to a new mental
model, and adapting to a very manual control system. When taxiing, having <a href="http://www.harmon.com/RudderPedals.htm">4
control surfaces at my feet</a> was pretty complex – seeing as I kept on thinking
of it like controlling handles on a bike steering column. I would instinctively push
right expecting to turn left, but got the hang of it more when I thought about it
as differential braking (even when I was using the nose wheel part of the control.)
My only point of minor helmet fire came at this point – when we needed to use differential
braking to make a turn, but my feet were only on the nose wheel portion of the control
(as suggested by the instructor.)
</p>
        <p align="center">
          <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="170" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstStepsinFlight_8B3E/image_14.png" width="244" border="0" />
        </p>
        <p>
          <br />
Oh, and ignoring my internal alarm bells is hard enough when starting an automatic
transmission car without depressing a clutch – an airplane was much worse.
</p>
        <p>
What surprised me most was how much input you had to give the controls. It felt like
there was a good 8 inches of travel in the foot pedals – much more than I was expecting.
I was sure I was going to rip the knob off of the dash when I was priming the engine.
</p>
        <p>
After we taxied, takeoff went pretty well. There was no traffic, so we didn’t burn
engine hours waiting in line. Actually leaving the pavement was weird, as I again
was expecting to need a subtle touch. After pushing the throttle forward slowly like
you see them do on big airplanes, the instructor told me to just gun it :) The climb
felt surprisingly manual as well, although the instructor did give me a rate of ascent
to aim for, which helped a lot. Once I visually leveled off, the instructor pointed
out that I was still climbing.  The nose definitely points a lot lower during
steady flight than it does during takeoff, but adapting to that came shortly.
</p>
        <p>
We did some minor orientation and directional work, and even got to do some nice steep
turns. The ceiling was really indefinite, and we had to avoid some cloud cover. The
runway approach went really well as we approached from the North. I guess since there
was no traffic, we basically did the 45 degree entry directly into an extended final
for the <a href="http://en.wikipedia.org/wiki/Airfield_traffic_pattern">traffic pattern</a>.
Lining up felt pretty natural, although I made the approach too low – I was aiming
for the numbers instead of the first dash.
</p>
        <p align="center">
          <a href="http://en.wikipedia.org/wiki/Airfield_traffic_pattern">
            <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="222" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstStepsinFlight_8B3E/image_17.png" width="513" border="0" />
          </a>
        </p>
        <p>
          <br />
So all-in-all, it was a great time up – and they seem like a very capable flight school.
</p>
        <p>
The next day, I took a flight with AcuWings, and I can understand why there is so
much support for them. Their office was a little hard to find at first (barely any
signs on an already nondescript office building,) but they seemed well-run. Their
office was off-base, so we had a very short drive across the road to the actual airplanes.
They will be getting a building on the field in the near future, so that will be convenient.
I followed the owner to the field who, despite his precision flying and deep knowledge
of flight rules, failed to use his signal light even once.
</p>
        <p>
For that intro flight, we flew their Cirrus SR20 (since I wanted to try a completely
different airplane.) Different it was – an ’07 model, tons of electronics, tons of
power, and no traditional yoke! You control the throttle with your right hand, and
control the direction with a joystick-like device on your left. The weather was beautiful:
in the mid-60s with unlimited ceiling, and 10 miles of visibility. This made for a
much busier airport, which was also good to experience.
</p>
        <p align="center">
          <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="186" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstStepsinFlight_8B3E/image_20.png" width="244" border="0" />     <img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height="190" alt="image" src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstStepsinFlight_8B3E/image_23.png" width="244" border="0" /></p>
        <p>
          <br />
My daughter joined us on this ride -- an experience I was thrilled to have been able
to share with her.
</p>
        <p>
The aircraft was a lot more responsive than the Cessna, so I initially pitched it
up to like 1100 ft/min correcting to the proper 700 ft/min or so during takeoff. We
climbed to 3500 feet, and were treated to an awesome view of Mount Rainier. With all
of the interactive electronics and gadgets, I had to consciously stop myself from
getting too absorbed in the pretty displays, and instead use the cockpit window for
what it was intended for :) We did some more level turns, played with the autopilot
a bit, and practiced throttle control.
</p>
        <p>
I was amazed to learn that airplanes will “skip” in the atmosphere. If you let them
go with wings level and drop the power, they will just settle on a new lower altitude
that matches the new power.
</p>
        <p>
After about half an hour in the air, we came back to the Renton base and ran a more
typical approach. We flew parallel to the runway (which I was surprised to realize
was 30ish degrees off of the North-South axis,) and made a short final from the South
due to heavy traffic. The landing went well, probably because it was almost entirely
under the control of my instructor :)
</p>
        <p>
After landing, it became very clear to me that this hobby has much more in store for
me. 
</p>
        <img width="0" height="0" src="http://www.leeholmes.com/blog/aggbug.ashx?id=b605a295-8e9a-4774-b529-06c4a73327ce" />
      </body>
      <title>First Steps in Flight</title>
      <guid isPermaLink="false">http://www.leeholmes.com/blog/PermaLink,guid,b605a295-8e9a-4774-b529-06c4a73327ce.aspx</guid>
      <link>http://www.leeholmes.com/blog/FirstStepsInFlight.aspx</link>
      <pubDate>Tue, 06 May 2008 17:03:21 GMT</pubDate>
      <description>&lt;p&gt;
For a long time, I've been thinking about learning to fly. One of the random long-distance-drive
conversations I like to have is, "What job would you do if you were for some reason
prevented from doing what you do now?" For me, flying has always been something I
would entertain, but only romantically. The downsides to doing it professionally are
huge -- the time away from your family and strict seniority-based promotions being
the two largest factors. So instead, I wanted to reward myself with flying lessons
the next time I thought it was appropriate. A King of the Hill episode, of all things,
changed my mind on that. 
&lt;/p&gt;
&lt;p align=center&gt;
&lt;img style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px" height=226 alt=image src="http://www.leeholmes.com/blog/content/binary/WindowsLiveWriter/FirstStepsinFlight_8B3E/image_3.png" width=204 border=0&gt; 
&lt;/p&gt;
&lt;p&gt;
In that episode, Hank (the father) and Peggy (the mother) were going through marital
problems, and spoke with a counselor. The counselor asked them what they wanted to
do when they retired -- something they had been planning toward for a long time. Their
dream was to buy some motorcycles and tour the United States together. The counselor's
suggestion was simple -- holding off on buying the bikes doesn't really help anything,
so just buy the darn things and start enjoying yourselves! The cross-country tours
can wait until you have the time to do them, but little local trips can happen right
now. 
&lt;/p&gt;
&lt;p&gt;
That started the slow chemical reaction in my brain, which ultimately led me to start
investigating flying lessons more seriously. 
&lt;/p&gt;
&lt;p&gt;
My typical obsessive online research turned up lots of information about learning
to fly. Tom Unger’s “&lt;a href="http://www.tumtum.com/flight/lessons/FlightLesson_1.shtml"&gt;Flying
Lessons&lt;/a&gt;” journal was indispensable, gave a lot of great background information,
and what to expect with the process. However, I found very little about picking a
flight school around the Seattle area, and sent a mail to an internal mailing list
asking for opinions. Four suggestions came up most frequently:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Pro-Flight Aviation: &lt;a href="http://www.flyproflight.com/"&gt;http://www.flyproflight.com/&lt;/a&gt; 
&lt;li&gt;
Galvin Flying Service: &lt;a href="http://www.galvinflying.com/"&gt;http://www.galvinflying.com/&lt;/a&gt; 
&lt;li&gt;
Acu-Wings: &lt;a href="http://www.acuwings.com/"&gt;http://www.acuwings.com/&lt;/a&gt; 
&lt;li&gt;
Alternate Air: &lt;a href="http://www.alternateair.com/"&gt;http://www.alternateair.com/&lt;/a&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
I ruled out Galvin immediately – their responses to customer complaints on &lt;a href="http://www.airnav.com/airport/KBFI/GALVIN"&gt;http://www.airnav.com/airport/KBFI/GALVIN&lt;/a&gt; were
ridiculous and showed complete disregard for their customers. 
&lt;/p&gt;
&lt;p&gt;
I ended up looking for operations out of the Renton Municipal Airport (KRNT) as my
primary factor. It’s close to my house, and commute time seems to be the most important
element in choosing a base. Airport traffic and other factors can be learned at other
airports (such as Crest Airpark for its crazy small field, and Boeing Field for its
busy airspace,) since most of your practice take-offs and landings come from explicit
training exercises (as opposed to being dictated by the base you fly from.)
&lt;/p&gt;
&lt;p&gt;
I first checked out Pro-Flight during a 9:00 AM intro flight, taking up a well-loved
Cessna 172. Introductory flights are an amazing deal – even as a leisure activity.
They cost under $100 for a scenic tour of the Puget Sound, and you get to do most
of the flying yourself. 
&lt;/p&gt;
&lt;p 