<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tinyint.com</title>
	<atom:link href="http://www.tinyint.com/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tinyint.com</link>
	<description>An engineering and development &#60;em&#62;Factory of Knowledge&#60;/em&#62;™</description>
	<lastBuildDate>Tue, 08 May 2012 19:12:11 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Printable ZoomIt shortcut card</title>
		<link>http://www.tinyint.com/index.php/2012/05/08/printable-zoomit-shortcut-card/</link>
		<comments>http://www.tinyint.com/index.php/2012/05/08/printable-zoomit-shortcut-card/#comments</comments>
		<pubDate>Tue, 08 May 2012 19:05:58 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=320</guid>
		<description><![CDATA[As a Premier Field Engineer, I am constantly doing presentations and delivering workshops to large groups of people, usually about PowerShell.  One of my favorite tools to use is ZoomIt which is part of the SysInternals suite.  I may not use ZoomIt for its &#8220;break&#8221; feature since I have my display-countdown script, but it&#8217;s a [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tinyint.com/wp-content/plugins/download-monitor/download.php?id=9"><img class="alignnone size-full wp-image-323" title="ZoomIt Shortcut Card" src="http://www.tinyint.com/wp-content/uploads/2012/05/zoomit-small.png" alt="" width="550" height="292" /></a></p>
<p>As a Premier Field Engineer, I am constantly doing presentations and delivering workshops to large groups of people, usually about PowerShell.  One of my favorite tools to use is <a href="http://technet.microsoft.com/en-us/sysinternals/bb897434">ZoomIt</a> which is part of the SysInternals suite.  I may not use ZoomIt for its &#8220;break&#8221; feature since I have my <a title="PowerShell Countdown Timer" href="http://www.tinyint.com/index.php/2011/08/28/powershell-countdown-timer/">display-countdown</a> script, but it&#8217;s a really great tool.  It can however be difficult to remember all of the shortcut keys if you haven&#8217;t used it before (and even to someone who uses it all of the time).  A while back I created a little printable card of all of the shortcut keys that are built in so I could tape it to the presentation screen and never fumble through it.  I decided to redo the card using a metro inspired design and am now sharing it with you!</p>
<p><em>The image is set up for 300 dpi and will print the same size as a business card.  Be sure to print it with the best options set on your printer and maybe you can even laminate it, if you want, and <a href="http://briantjackett.com/archive/2012/02/29/what-i-pack-in-my-travel-backpack.aspx">keep it in your gear bag</a>.</em></p>
<p><strong>Download the high-res version: <a href="http://www.tinyint.com/wp-content/plugins/download-monitor/download.php?id=9">Printable ZoomIt Shortcut Card</a>.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2012/05/08/printable-zoomit-shortcut-card/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get-Help for .Net types in PowerShell</title>
		<link>http://www.tinyint.com/index.php/2012/02/16/get-help-for-net-types-in-powershell/</link>
		<comments>http://www.tinyint.com/index.php/2012/02/16/get-help-for-net-types-in-powershell/#comments</comments>
		<pubDate>Thu, 16 Feb 2012 05:32:01 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=311</guid>
		<description><![CDATA[One thing I hear people ask about with PowerShell pretty frequently is regarding the fact that reference information for underlying .Net types is not available through the Get-Help cmdlet. While I can certainly understand the frustration, there is unfortunately little that can be done about it since the .Net reference documentation is not included with [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I hear people ask about with PowerShell pretty frequently is regarding the fact that reference information for underlying .Net types is not available through the Get-Help cmdlet. While I can certainly understand the frustration, there is unfortunately little that can be done about it since the .Net reference documentation is not included with PowerShell.</p>
<p><img alt="" src="http://www.tinyint.com/wp-content/uploads/2012/02/no-help1.png" /></p>
<p>While Get-Member can give us an awful lot of information about the methods, properties, and other members of a specific object, you have to jump through a few hoops to make all of the information display in an easy to read format. If you want to see static members you have to change around your call to Get-Member entirely.&nbsp; The only way to get real reference / help information is to open up the MSDN library and look the information up.</p>
<p>This got me thinking, instead of dealing with all of the MSDN documentation manually, why not just create a script that will open up MSDN for me to the page about the specified type? This isn&#39;t a difficult process, but there are many different URLs that the script would have to be aware of to make sure it always loads the correct page that it became a bit messy. Therefore I opted for a much simpler option: just make the script load the MSDN search page with the specified type queried for me.</p>
<p>&nbsp;</p>
<p><em>Jump past the break for more info and to download the script</em></p>
<p><span id="more-311"></span></p>
<p>The script allows input in the form of Type, MemberInformation, or just a String. The nice thing with MemberInformation is that you can do something like:
<pre class="brush: powershell; title: ; notranslate">Get-ChildItem | Get-Member | .\Find-TypeReference.ps1</pre>
<p> This will send the member information Get-Member returns and will look through it to figure out the data type and then pass it off to the web browser.</p>
<p>Since not every type will be defined in the .Net Framework because some could be third party types that don&#39;t exist on MSDN it also allows you to open up Bing instead to do the search. Combine this with the fact that it allows you to specify a string query, and now you have a function that will not only search for type information based on objects piped into it, but also open up a search for just about any query you can think of.</p>
<p>Additionally, this script uses ShouldProcess to make sure you don&#39;t pass in hundreds of different types and end up bringing your computer to a crawl by launching too many instances of a web browser for the search page.&nbsp; <em>Stay tuned for a future post which will talk about ShouldProcess and how to use it in your own scripts.</em></p>
<p><em><strong><a href="http://www.tinyint.com/wp-content/plugins/download-monitor/download.php?id=8"><img alt="Download Find-TypeReference.ps1" border="0" src="/images/download.png" style="width: 48px; height: 48px; border-width: 0pt; border-style: solid; vertical-align: middle;" title="Download Find-TypeReference.ps1" /><span style="font-size:14px;">Download Find-TypeReference.ps1</span></a></strong><br /><br /></em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2012/02/16/get-help-for-net-types-in-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get an MD5 or SHA1 Checksum with PowerShell</title>
		<link>http://www.tinyint.com/index.php/2011/09/14/get-an-md5-or-sha1-checksum-with-powershell/</link>
		<comments>http://www.tinyint.com/index.php/2011/09/14/get-an-md5-or-sha1-checksum-with-powershell/#comments</comments>
		<pubDate>Wed, 14 Sep 2011 08:04:26 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[checksum]]></category>
		<category><![CDATA[md5]]></category>
		<category><![CDATA[sha1]]></category>
		<category><![CDATA[windows 8]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=288</guid>
		<description><![CDATA[I was excited about the Windows 8 developer preview that was released earlier tonight, so I fired up Virtual PC to start playing around with it.&#160; I ended up with an error when it was loading so I thought maybe I had a bad copy of the ISO so I thought &#34;I know, I&#39;ll do [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.tinyint.com/wp-content/uploads/2011/09/get-checksum.png" rel="" target="" title=""><img alt="" class="alignnone size-full wp-image-297" height="271" src="http://www.tinyint.com/wp-content/uploads/2011/09/get-checksum.png" style="border: 0px currentColor;" title="get-checksum" width="600" /></a></p>
<p>I was excited about the <a href="http://msdn.microsoft.com/en-us/windows/apps/br229516">Windows 8 developer preview</a> that was released earlier tonight, so I fired up Virtual PC to start playing around with it.&nbsp; I ended up with an error when it was loading so I thought maybe I had a bad copy of the ISO so I thought &quot;I know, I&#39;ll do a&nbsp;checksum test.&quot;&nbsp; Unfortunately, I don&#39;t have a tool to take a checksum on my current machine so naturally I wrote a simple function in PowerShell to do the checksum test for me.</p>
<p>It has only a few simple parameters that you can enter, file and algorithm.&nbsp; &quot;File&quot; is for the actual file you want to checksum.&nbsp; &quot;Algorithm&quot; is either &quot;sha1&quot; or &quot;md5&quot; and will let you get both an MD5 and a SHA1 checksum of the specified file.</p>
<p>Update: If you came here looking for the SHA1/MD5 hashes for the Windows 8 CTP iso&#8217;s, here you go.</p>
<p><strong>Windows Developer Preview with developer tools English, 64-bit (x64)</strong><br/><strong>SHA1: </strong>6FE9352FB59F6D0789AF35D1001BD4E4E81E42AF<br /><strong>MD5: </strong>116EB08542BB48FE4314BB6DEA39335E</p>
<p><strong>Windows Developer Preview English, 64-bit (x64)</strong><br /><strong>SHA1: </strong>79DBF235FD49F5C1C8F8C04E24BDE6E1D04DA1E9<br /><strong>MD5: </strong>DFCB53C7B32351784C37E5DE0A7B1167</p>
<p><strong>Windows Developer Preview English, 32-bit (x86)</strong><br /><strong>SHA1: </strong>4E0698BBABE01ED27582C9FC16AD21C4422913CC<br /><strong>MD5: 9B7798438FA694ECFA465C93A4C23C97</strong></p>
<p>&nbsp;</p>
<p><em>You can download the full script after the jump.</em></p>
<p><span id="more-288"></span></p>
<p><pre class="brush: powershell; title: ; notranslate">
function Get-Checksum
{
    Param (
        [string]$File=$(throw(&quot;You must specify a filename to get the checksum of.&quot;)),
        [ValidateSet(&quot;sha1&quot;,&quot;md5&quot;)]
        [string]$Algorithm=&quot;sha1&quot;
    )

    $fs = new-object System.IO.FileStream $File, &quot;Open&quot;
    $algo = [type]&quot;System.Security.Cryptography.$Algorithm&quot;
	$crypto = $algo::Create()
    $hash = [BitConverter]::ToString($crypto.ComputeHash($fs)).Replace(&quot;-&quot;, &quot;&quot;)
    $fs.Close()
    $hash
}
</pre></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2011/09/14/get-an-md5-or-sha1-checksum-with-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PowerShell Countdown Timer</title>
		<link>http://www.tinyint.com/index.php/2011/08/28/powershell-countdown-timer/</link>
		<comments>http://www.tinyint.com/index.php/2011/08/28/powershell-countdown-timer/#comments</comments>
		<pubDate>Mon, 29 Aug 2011 01:38:52 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[countdown]]></category>
		<category><![CDATA[timer]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=266</guid>
		<description><![CDATA[&#160; As a Premier Field Engineer for Microsoft, I&#39;m often presenting workshops to classrooms of people on various technologies.&#160; During these workshops we take breaks and work on labs and it&#39;s nice to have some kind of countdown timer to show the attendees how much time is left in a break or until we begin [...]]]></description>
			<content:encoded><![CDATA[<p>&nbsp;<a href="http://www.tinyint.com/wp-content/uploads/2011/08/display-countdown.png"><img alt="" class="alignnone size-full wp-image-267" src="http://www.tinyint.com/wp-content/uploads/2011/08/display-countdown.png" style="border-width: 0px; border-style: solid; width: 618px; height: 357px;" title="display-countdown" /></a></p>
<p>As a Premier Field Engineer for Microsoft, I&#39;m often presenting workshops to classrooms of people on various technologies.&nbsp; During these workshops we take breaks and work on labs and it&#39;s nice to have some kind of countdown timer to show the attendees how much time is left in a break or until we begin the next module for example.</p>
<p>Sysinternals has a very useful tool called <a href="http://technet.microsoft.com/en-us/sysinternals/bb897434 ">ZoomIt</a>&nbsp;which allows presenters to zoom in, draw, and even display a countdown timer on the screen.&nbsp; While this tool is well designed and is even used by many PFE&rsquo;s around the world, including myself, and while it includes useful features such as playing a sound when the timer has completed and even displaying a background image, it left me wanting more.&nbsp; I just wanted something basic that I could use when presenting PowerShell material that would allow me to simply specify a time and a message&#8230; <em>so I made my own.</em></p>
<p><em>Head after the jump to download the script.</em></p>
<p><span id="more-266"></span></p>
<p>I wrote a script that would allow me to display a popup countdown timer from within the PowerShell console.&nbsp; The script I wrote is provides two different countdown timers: one is very basic and just displays a simple two line countdown, the other is a bit more advanced and displays an &ldquo;F7 style&rdquo; popup window like in the screenshot above.&nbsp; It looks pretty nice even though you&#39;re still limited to the font size of your shell (I always have mine set high (12&#215;16) for projection screens anyway).&nbsp; You can use the built-in Windows magnifier to enlarge it even more if you really want.</p>
<p>Here are a few usage examples, but you can see everything by&nbsp;looking at the comment-based help by running&nbsp;<span style="font-family: courier new,courier,monospace;">get-help .\display-countdown.ps1 -full</span></p>
<p><strong>Usage examples:</strong></p>
<blockquote>
<p><strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; EXAMPLE 1 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</strong></p>
<p><strong>C:\PS>.\display-countdown.ps1 -Minutes 15 -Message &quot;Time until break is over&quot;</strong></p>
<p><strong>This will display a simple text-based countdown that will expire 15 minutes from the time it was called, displaying the specified message as a header.</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; EXAMPLE 2 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</strong></p>
<p><strong>C:\PS>.\display-countdown.ps1 -Until (get-date).AddHours(1) -Message &quot;Lunch break&quot; -Popup</strong></p>
<p><strong>This will display a countdown timer that will expire in one hour from the time it was called, displayed &quot;Lunch break&quot; as the caption.&nbsp; This example displays in the more user friendly popup mode.</strong></p>
<p><strong>&nbsp;</strong></p>
<p><strong>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211; EXAMPLE 3 &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</strong></p>
<p><strong>C:\PS>.\display-countdown.ps1 -Countdown ([TimeSpan]::FromMinutes(10)) -Message &quot;Bio Break&quot; -NoClear</strong></p>
<p><strong>This will display a simple text-based countdown that will expire 10 minutes from the time it was called, displaying &quot;Bio Break&quot; as the header.&nbsp; This call does not clear the screen of its contents before running.&nbsp;</strong></p>
</blockquote>
<p>&nbsp;</p>
<strong><a href="http://www.tinyint.com/wp-content/plugins/download-monitor/download.php?id=7"><img alt="Download display-countdown.ps1" border="0" src="/images/download.png" style="width: 48px; height: 48px; border-width: 0pt; border-style: solid; vertical-align: middle;" title="Download display-countdown.ps1" /><span style="font-size:14px;">Download display-countdown.ps1</span></a></strong><br /><br />
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2011/08/28/powershell-countdown-timer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Escaping quotes in powershell.exe -command via command prompt</title>
		<link>http://www.tinyint.com/index.php/2011/04/20/escaping-quotes-in-powershell-exe-command-via-command-prompt/</link>
		<comments>http://www.tinyint.com/index.php/2011/04/20/escaping-quotes-in-powershell-exe-command-via-command-prompt/#comments</comments>
		<pubDate>Wed, 20 Apr 2011 07:00:02 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[Powershell]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=211</guid>
		<description><![CDATA[An interesting situation came up recently that involved having to execute a PowerShell script through the cmd.exe command prompt. It sounds pretty simple, after all you can simply run powershell.exe –file &#8220;&#60;path_to_script&#62;&#8221; and call it a day. That wasn&#8217;t the case here though because the –File parameter is only available in PowerShell V2 and this [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.tinyint.com/wp-content/uploads/2011/04/cmd-no-escape.png" alt="" title="Command Line - No Escape Character" width="517" height="306" class="alignnone size-full wp-image-219" /></p>
<p>An interesting situation came up recently that involved having to execute a PowerShell script through the cmd.exe command prompt.  It sounds pretty simple, after all you can simply run powershell.exe –file &#8220;&lt;path_to_script&gt;&#8221; and call it a day.  That wasn&#8217;t the case here though because the –File parameter is only available in PowerShell V2 and this situation was dealing with V1.  The only option then is to use the -command argument of powershell.exe and to execute the necessary code.  This works great, but if you need to include a string with quotes, you may have some trouble.<br />
<span id="more-211"></span><br />
<em>Scroll to the end for the summary if you just want to see how to properly get quotes into your powershell.exe -command argument.</em></p>
<p>Within PowerShell, it is incredibly simple to execute a script (assuming your script is signed or you have the execution policy set appropriately).  There are a few gotchas that people get caught up on when they are starting out with PowerShell so I&#8217;ll quickly cover them first.</p>
<p>We want to execute the script, so we just provide the full path to the script and hit enter, right?</p>
<p><img src="http://www.tinyint.com/wp-content/uploads/2011/04/posh-no-quotes.png" title="PowerShell - No Quotes" width="517" height="306" class="alignnone size-full wp-image-216" /></p>
<p>That didn&#8217;t work because of the spaces in the path.  Ok, then we just proceed like we would in a command prompt and put the path in quotes, right?</p>
<p><img src="http://www.tinyint.com/wp-content/uploads/2011/04/posh-quotes.png" alt="" title="PowerShell - Quotes" width="517" height="306" class="alignnone size-full wp-image-223" /></p>
<p>Unfortunately that doesn&#8217;t work either because now you are just telling PowerShell &#8220;Hey, here is a string&#8221; and it simply spits it back out to you.  The correct procedure is to use the <a href="http://technet.microsoft.com/en-us/library/dd347588.aspx">Call operator</a> with the entire path in quotes and it should work out fine.</p>
<p><img src="http://www.tinyint.com/wp-content/uploads/2011/04/posh-operator.png" alt="" title="PowerShell - Call Operator" width="517" height="306" class="alignnone size-full wp-image-222" /></p>
<p>Then, if we want to use the <a href="http://technet.microsoft.com/en-us/library/dd347713.aspx">environment variable</a> for the program files directory, we can just do the following:</p>
<p><img src="http://www.tinyint.com/wp-content/uploads/2011/04/posh-environment.png" alt="" title="PowerShell - Environment Variable" width="517" height="306" class="alignnone size-full wp-image-221" /></p>
<p>Now that we know the proper command syntax, we need to switch over to a command prompt, since this script has to be executed from there.  We know that powershell.exe can accept a <a href="http://technet.microsoft.com/en-us/library/dd315276.aspx">–Command parameter</a> which should allow us to execute the same command we just figured out within the PowerShell prompt.</p>
<p><img src="http://www.tinyint.com/wp-content/uploads/2011/04/cmd-no-escape.png" alt="" title="Command Line - No Escape Character" width="517" height="306" class="alignnone size-full wp-image-219" /></p>
<p>That doesn&#8217;t work, but what exactly is going on here?  Based on the output of the error, we can see that the environment variable is being expanded appropriately, but it looks like everything past &#8220;script&#8221; is being interpreted as an additional parameter.  With this in mind, it seems like it&#8217;s a simple matter of having to escape the quotation marks around the path of the script to make sure it&#8217;s interpreted as a single value.  Because we are in a dos prompt though, the first thought might be to use a caret (^) to escape the quotes, which is something we <a href="http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/ntcmds_shelloverview.mspx?mfr=true">do all the time in batch files</a>.</p>
<p><img src="http://www.tinyint.com/wp-content/uploads/2011/04/cmd-dos-escape.png" alt="" title="Command Line - DOS Escape Character (^ - Caret)" width="517" height="306" class="alignnone size-full wp-image-218" /></p>
<p>That doesn&#8217;t work either, but the error is slightly different this time.  Instead of the intended result of having a quotation mark, the quotes are actually dropped and the caret is inserted.  So clearly the caret didn&#8217;t help, so next we try the <a href="http://technet.microsoft.com/en-us/library/dd347662.aspx">PowerShell escape character</a>, the grave accent (`).  This may make more sense because the logic is that whatever is inside the outer quotes, gets passed into the PowerShell executable, then the rest of it gets interpreted. Therefore we need PowerShell to be aware of what we are doing.</p>
<p><img src="http://www.tinyint.com/wp-content/uploads/2011/04/cmd-psh-escape.png" alt="" title="Command Line - PowerShell Escape Character (` - Grave Accent)" width="517" height="306" class="alignnone size-full wp-image-220" /></p>
<p>Interestingly, the environment variable isn&#8217;t being expanded now; additionally the grave accent isn&#8217;t being passed at all.  It&#8217;s as if PowerShell is completely disregarding the text we are inputting.  </p>
<p>So what is actually going on here?  As it turns out, we aren&#8217;t dealing with an issue with choosing the right escape character for DOS, or the right escape character for PowerShell.  The problem is that we need to use an escape character that the PowerShell argument parser can understand.  The powershell.exe binary isn&#8217;t a batch file or powershell script, it is an actual compiled program and as such has to actually parse the arguments that are given to it.  With that in mind, we need to use the appropriate escape character, the backslash (\).</p>
<p><img src="http://www.tinyint.com/wp-content/uploads/2011/04/cmd-c-escape.png" alt="" title="Command Line - C Escape Character (\ - Back slash)" width="517" height="306" class="alignnone size-full wp-image-217" /></p>
<p><strong>So what is the conclusion here?</strong>  When trying to execute a command in PowerShell via the -Command argument of powershell.exe, be sure to escape your quotes with the C style back slash.  </p>
<p>This behavior is by design, there is no doubt there.  Ultimately, it all comes down to how the application (powershell.exe in our case) parses the command line arguments.  PowerShell handles it this way whereas another app could in theory have it&#8217;s own, completely made-up, set of escape characters for arguments that are enclosed in quotes.  While it may be confusing when trying to execute commands via the PowerShell binary, this actually is logical behavior when you think about it, and once you are aware of how it works, you will likely never forget.  </p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2011/04/20/escaping-quotes-in-powershell-exe-command-via-command-prompt/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASP.NET Code Delimiters</title>
		<link>http://www.tinyint.com/index.php/2011/01/19/asp-net-code-delimiters/</link>
		<comments>http://www.tinyint.com/index.php/2011/01/19/asp-net-code-delimiters/#comments</comments>
		<pubDate>Thu, 20 Jan 2011 00:51:38 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[ASP.Net]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=193</guid>
		<description><![CDATA[When working in ASP.Net there are a number of code delimiters you need to be aware of, the most recognizable one is &#60;% which, for anyone who has worked with anything from Classic ASP 1.0 (anyone remember IIS 3?) through ASP.Net 4.0 will recognize. Some people call them ASP.net tags or code shortcuts, both of [...]]]></description>
			<content:encoded><![CDATA[<p>When working in ASP.Net there are a number of <strong>code delimiters</strong> you need to be aware of, the most recognizable one is &lt;% which, for anyone who has worked with anything from Classic ASP 1.0 (anyone remember IIS 3?) through ASP.Net 4.0 will recognize.  Some people call them ASP.net <em>tags</em> or <em>code shortcuts</em>, both of which are only partly true.  Calling them &#8220;<em>tags</em>&#8221; is a little misleading because ASP.NET <em>tags</em> are really things such as &#8220;<code>&lt;asp:DropDownList /&gt;</code>&#8221; and &#8220;<code>&lt;asp:ListItem /&gt;</code>&#8220;.  Calling them <em>code shortcuts</em> is a bit misleading as well because, while some of them are shortcuts (<code>&lt;%= ... %&gt;</code> is a shortcut for <code>&lt;% Response.Write (...) %&gt;</code>) not all of them have this kind of purpose.<br />
<span id="more-193"></span><br />
While &#8220;code delimiter&#8221; sometimes refers explicitly to the left carat + percent sign and percent sign + right carat only, the verbiage used in Microsoft documentation is usually &#8220;code delimiter&#8221; and as such is what I am going to refer to them throughout this post.  There are a number of different code delimiters available to an ASP.Net developer, but a beginner might have a bit of trouble finding out what they all do.  Microsoft lists the majority of them in the ASP.Net Page Syntax section of MSDN (<a href="http://msdn.microsoft.com/en-us/library/fy30at8h.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/fy30at8h.aspx</a>) but this post is meant to be a quick access list of those delimiters.  While an experienced developer is going to be intimately familiar with all of these, I thought it would be useful to write a short post to list all of them.</p>
<p>One thing to note about the examples I am using below: they are only intended to show how these would look in a block of code, rather than demonstrate real-world usage.  Refer to the MSDN article links for more detail on actual usage of each delimiter.</p>
<p>So, without further ado, here is the full list of ASP.NET code delimiters.</p>
<div style="padding-top: 18px; margin-top: 18px; border-top: 1px dashed #888888;">
<strong style="font-size: 15px;">&#8220;<code>&lt;% ... %&gt;</code>&#8220;</strong> &#8211; The first code delimiter I will mention is for embedding blocks of inline code (<a href="http://msdn.microsoft.com/en-us/library/k6xeyd4z.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/k6xeyd4z.aspx</a>)</p>
<pre class="brush: vb; title: ; notranslate">
&lt;%
'Basic inline code block
For x = 1 to 100
    Response.Write string.Format(&quot;x = {0}&lt;br /&gt;&quot;, x)
Next
%&gt;
</pre>
</div>
<div style="padding-top: 18px; margin-top: 18px; border-top: 1px dashed #888888;">
<strong style="font-size: 15px;">&#8220;<code>&lt;%= ... %&gt;</code>&#8220;</strong> &#8211; The next code delimiter is also for inline code but specifically a shortcut to the inline code block <strong style="font-size: 15px;">&#8220;<code>&lt;% Response.Write ( ... ) %&gt;</code>&#8220;</strong>.  (<a href="http://msdn.microsoft.com/en-us/library/k6xeyd4z.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/k6xeyd4z.aspx</a>)</p>
<pre class="brush: vb; title: ; notranslate">
Current Date and Time: &lt;%= DateTime.Now().ToString() %&gt;
</pre>
</div>
<div style="padding-top: 18px; margin-top: 18px; border-top: 1px dashed #888888;">
<strong style="font-size: 15px;">&#8220;<code>&lt;%-- ... --%&gt;</code>&#8220;</strong> &#8211; Another delimiter that is a shortcut of sorts, perhaps a lesser known one though, is the server-side comment.  It is simply used for commenting out information that you don&#8217;t want to get sent off to the client.  There is a gotcha to the server-side comment however, that you cannot use it in embedded code blocks, which will actually cause a compilation error if you try.  (<a href="http://msdn.microsoft.com/en-us/library/4acf8afk.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/4acf8afk.aspx</a>)</p>
<pre class="brush: vb; title: ; notranslate">
&lt;%-- You can use a server side comment to keep information from getting to the browser of a user --%&gt;
</pre>
</div>
<div style="padding-top: 18px; margin-top: 18px; border-top: 1px dashed #888888;">
<strong style="font-size: 15px;">&#8220;<code>&lt;%@ ... %&gt;</code>&#8220;</strong> &#8211; The template directive is an important delimiter, one that the majority of ASP.Net web forms pages will have on them.  There are quite a few different directives that you need to be familiar with, and not all are for web forms pages, but the most common one is probably the page directive, which allows you to specify code behind, master pages, enable or disable viewstate, buffering options, and a plethora of others.  (<a href="http://msdn.microsoft.com/en-us/library/xz702w3e.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/xz702w3e.aspx</a>)</p>
<pre class="brush: vb; title: ; notranslate">
&lt;%@ Page Title=&quot;Home&quot; Language=&quot;VB&quot; MasterPageFile=&quot;~/Site.master&quot; AutoEventWireup=&quot;false&quot; CodeFile=&quot;Default.aspx.vb&quot; Inherits=&quot;_Default&quot; EnableSessionState=&quot;False&quot; %&gt;
</pre>
</div>
<div style="padding-top: 18px; margin-top: 18px; border-top: 1px dashed #888888;">
<strong style="font-size: 15px;">&#8220;<code>&lt;%# ... %&gt;</code>&#8220;</strong> &#8211; Data-binding expressions are the next important set of code delimiters, which are used to create a binding between a server control property and a data source.  (<a href="http://msdn.microsoft.com/en-us/library/bda9bbfx.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/bda9bbfx.aspx</a>)</p>
<pre class="brush: vb; title: ; notranslate">
&lt;asp:DropDownList ID=&quot;ddlInsertUser&quot;
                        SelectedValue='&lt;%# Bind(&quot;UserID&quot;) %&gt;'
                        DataSourceID=&quot;UsersDataSource&quot;
                        DataTextField=&quot;UserName&quot;
                        DataValueField=&quot;UserID&quot;
                        RunAt=&quot;Server&quot; /&gt;
</pre>
</div>
<div style="padding-top: 18px; margin-top: 18px; border-top: 1px dashed #888888;">
<strong style="font-size: 15px;">&#8220;<code>&lt;%$ ... %&gt;</code>&#8220;</strong> &#8211; The last code delimiter to mention is the ASP.Net Expression delimiter. This delimiter allows you to set the properties of a control to an evaluated expression at runtime.  While this has many useful purposes, it is incredibly useful when localizing your web pages.  (<a href="http://msdn.microsoft.com/en-us/library/d5bd1tad.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/d5bd1tad.aspx</a>)</p>
<pre class="brush: vb; title: ; notranslate">
&lt;asp:Label id=&quot;label1&quot; runat=&quot;server&quot; text=&quot;&lt;%$ Resources: LocalizeData, WelcomeLabel %&gt;&quot; /&gt;
</pre>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2011/01/19/asp-net-code-delimiters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CA certificate expiration monitoring</title>
		<link>http://www.tinyint.com/index.php/2010/08/09/ca-certificate-expiration-monitoring/</link>
		<comments>http://www.tinyint.com/index.php/2010/08/09/ca-certificate-expiration-monitoring/#comments</comments>
		<pubDate>Mon, 09 Aug 2010 17:19:17 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[certificate services]]></category>
		<category><![CDATA[windows 2008]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=181</guid>
		<description><![CDATA[A reader sent me a message asking how to modify the original CA monitoring script I wrote back in November so that instead of monitoring the pending requests, it would send a message based on expiring certificates. The answer is just a modification to the certutil command that was used in the original script.  The new [...]]]></description>
			<content:encoded><![CDATA[<p>A reader sent me a message asking how to modify the <a href="http://www.tinyint.com/index.php/2009/11/24/certificate-authority-request-monitoring-with-powershell/">original CA monitoring script</a> I wrote back in November so that instead of monitoring the pending requests, it would send a message based on expiring certificates.  The answer is just a modification to the certutil command that was used in the original script.  The new script also allows you to specify the number of days advanced notification you are looking for, the default is 30 days.  Just keep in mind that if you run this script once a day, you will receive a notification every day until the certificate is either revoked/superseded or the certificate is passed the time period specified.  Of course this is all irrelevant if you have the money to spend on <a href="http://www.microsoft.com/systemcenter/en/us/operations-manager.aspx">SCOM</a> which can do this with one of the released <a href="http://www.microsoft.com/downloads/details.aspx?familyid=15edbfeb-0b7d-4baf-a7bd-6bb84a6b822d&amp;displaylang=en&amp;tm">management packs</a>.</p>
<p>The modified <a href="http://technet.microsoft.com/en-us/library/cc732443%28WS.10%29.aspx">certutil</a> command looks a bit like this:</p>
<pre class="brush: plain; title: ; notranslate">certutil -view -restrict &quot;NotAfter&gt;=8/9/2010,NotAfter&lt;=9/9/2010&quot; -out &quot;Request ID, Request Submission Date, Request Common Name, Requester Name, Request Email Address, Request Distinguished Name, CertificateTemplate, NotAfter&quot; -config &quot;&lt;CA_SERVER_NAME&gt;\&lt;CA_NAME&gt;&quot;</pre>
<p>This will return to you all of the certificates that are scheduled to expire between today (August 9th, 2010) and 30 days from now (September 9th, 2010)</p>
<p>You can download the new script here: <strong><a href="http://www.tinyint.com/wp-content/plugins/download-monitor/download.php?id=5"><img alt="Download monitor_ca_expiry.ps1" border="0" src="/images/download.png" style="width: 48px; height: 48px; border-width: 0pt; border-style: solid; vertical-align: middle;" title="Download monitor_ca_expiry.ps1" /><span style="font-size:14px;">Download monitor_ca_expiry.ps1</span></a></strong><br /><br /></p>
<p><strong>Update</strong>: Thanks to Aaron (from New Mexico? the original reader) who noticed I forgot one really useful bit of information from the status report that displays when you run the command: the date of expiration for the certificate.  I have updated the script and the sample above to reflect the change.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2010/08/09/ca-certificate-expiration-monitoring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Certificate Authority Request Monitoring with Powershell</title>
		<link>http://www.tinyint.com/index.php/2009/11/24/certificate-authority-request-monitoring-with-powershell/</link>
		<comments>http://www.tinyint.com/index.php/2009/11/24/certificate-authority-request-monitoring-with-powershell/#comments</comments>
		<pubDate>Tue, 24 Nov 2009 23:26:46 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[certificate services]]></category>
		<category><![CDATA[windows 2008]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=166</guid>
		<description><![CDATA[Rolling out a certificate authority in Windows 2003 and Windows 2008 is a relatively trivial task if you are deploying a stand-alone CA, Enterprise CA’s are a bit more complex, but that&#8217;s a post for another day. The web interface (http://server.domain.local/certsrv/) is pretty limited and doesn’t provide the greatest interface for manually requesting certificates, it [...]]]></description>
			<content:encoded><![CDATA[<p>Rolling out a certificate authority in Windows 2003 and Windows 2008 is a relatively trivial task if you are deploying a stand-alone CA, Enterprise CA’s are a bit more complex, but that&#8217;s a post for another day.  The web interface (http://server.domain.local/certsrv/) is pretty limited and doesn’t provide the greatest interface for manually requesting certificates, it even relies on cookies for managing requests.  It would be really nice to see Microsoft build this into a truly useful application like what you get with the <a href="https://ssl-certificate-center.thawte.com/process/retail/console_login?application_locale=THAWTE_US">Thawte Certificate Center</a>.</p>
<p>One thing that is a bit frustrating is that even when you have the logging options fully enabled for the CA, events aren’t logged for new certificate requests so you have to manually check the server on a regular basis for outstanding requests.  Usually this is a low priority kind of service in your enterprise and can get neglected, which has happened in my case a few times.</p>
<p>This neglect prompted me to write the following Powershell script which very simply uses <a href="http://technet.microsoft.com/en-us/library/cc732443%28WS.10%29.aspx">certutil</a> to check if there are any pending requests, and then fire off an email to a list of users if there are.  This script could also be easily modified to check for revoked certificates or to generate a weekly report on existing certificates to monitor expiration dates, among a bunch of other things, however I really only needed this for requests so that&#8217;s all it does for right now.  If anyone has any interest in something else, let me know and I’ll see about updating the script to include additional features.</p>
<p>To use this script, all you need to do is ensure you have a copy of certutil on the machine running this, update the configurable pieces of the script, then create a scheduled task to run it every hour or so, or whatever time-frame is appropriate for you and your organization.</p>
<p>More information and a download link is after the break&#8230;<br />
<span id="more-166"></span></p>
<p>The script uses a very simple function of certutil to check for pending requests.  You can execute the following code from a command prompt or powershell prompt to see a list of existing pending requests.</p>
<pre class="brush: plain; title: ; notranslate">

certutil -view -out &quot;Request ID, Request Submission Date, Request Common Name, Requester Name, Request Email Address, Request Distinguished Name, CertificateTemplate, Request Disposition&quot; -Restrict &quot;Request Disposition=9&quot; -config &quot;&lt;CA_SERVER_NAME&gt;\&lt;CA_NAME&gt;&quot;
</pre>
<p>Basically what this is doing is it is telling certutil to check for any certificates where the request dispoition is 9, in other words, any pending certificate requests.  It then outputs a few usefull properties related to the certificates.  All you need to change is the part with &#8220;\&#8221; to include the valid server and name.</p>
<p><strong>Note: </strong>You can omit the entire &#8220;-config &#8220;&lt;CA_SERVER_NAME&gt;\&lt;CA_NAME&gt;&#8221;" piece if you are running this locally from the CA server and only want to retrieve the local information.</p>
<p><strong>For the full powershell script, click the download link here:</strong> <strong><a href="http://www.tinyint.com/wp-content/plugins/download-monitor/download.php?id=4"><img alt="Download monitor_ca_requests.ps1" border="0" src="/images/download.png" style="width: 48px; height: 48px; border-width: 0pt; border-style: solid; vertical-align: middle;" title="Download monitor_ca_requests.ps1" /><span style="font-size:14px;">Download monitor_ca_requests.ps1</span></a></strong><br /><br /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2009/11/24/certificate-authority-request-monitoring-with-powershell/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>vSphere Client on Windows 7</title>
		<link>http://www.tinyint.com/index.php/2009/09/04/vsphere-client-on-windows-7/</link>
		<comments>http://www.tinyint.com/index.php/2009/09/04/vsphere-client-on-windows-7/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 22:27:47 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[Powershell]]></category>
		<category><![CDATA[VMware]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[vsphere]]></category>
		<category><![CDATA[windows 7]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=122</guid>
		<description><![CDATA[Update 2010-03-03: Keep in mind that this was fixed in vSphere 4 Update 1. Although if you can&#8217;t move to Update 1 for some reason, this will still work. Update 2009-09-08: I just updated the script because I received a report from wohali (Joan) over at VMware communities that they had a problem when the [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Update 2010-03-03: Keep in mind that this was fixed in vSphere 4 Update 1.  Although if you can&#8217;t move to Update 1 for some reason, this will still work.</p></blockquote>
<blockquote><p>Update 2009-09-08: I just updated the script because I received a report from wohali (Joan) over at VMware communities that they had a problem when the vSphere client was installed on a different drive and I have now fixed that problem.  I also added in support for making the host update utility work as well.  Lastly, I added a few output messages so you can see what&#8217;s going on and know what is getting done.</p></blockquote>
<p>The past few months I have been enjoying <a href="http://www.microsoft.com/windows/windows-7/">Windows 7</a> quite a bit (both the RC and now the RTM), but at the office we use VMware for many of our clients and the vSphere Client unfortunately has an issue with Windows 7 due to an incompatibility with a .Net 2.0 library dll that comes installed on Windows 7.  When you install the vSphere client, you will be able to get through the install without an issue usually (If you have <a href="http://communities.vmware.com/thread/211494">J# already installed</a> you may encounter issues installing the vSphere client), but once you try to connect to your vSphere server you get an error stating “Error parsing &lt;server&gt; clients.xml file  Login will continue contact your system administrator” followed immediately by another error “The type initializer for &#8220;VirtualInfrastrcture.Utils.HttpWebRequestProxy&#8221; threw an exception” which then brings you back to the login screen and you are unable to connect in.<br />
<span id="more-122"></span><br />
There’s big <a href="http://communities.vmware.com/thread/211440">thread</a> over at VMware Communities that discusses this problem and ways to fix it.  Unfortunately, it’s a manual process and deploying this out to all of our Windows 7 employee workstations is a bit of a hassle, so I have created a Powershell script that will do the necessary work for you, and create a shortcut on your desktop as well.</p>
<p>By default, powershell security options may prevent you from executing the script, so you may have to change a setting temporarily to get it to work.  If you type “<a href="http://technet.microsoft.com/en-us/library/dd347644.aspx">Get-ExecutionPolicy</a>” from a powershell window you will most likely see “Restricted” but there are a few others as well which will all prevent you from executing the script.  You can read more about this over at dotnetvj.com where he goes into a little more detail about these execution policies and what they mean.  All you need to do though is type “<a href="http://technet.microsoft.com/en-us/library/dd347628.aspx">Set-ExecutionPolicy</a> Unrestricted”  Just remember that you should probably set the execution policy back to its previous value after you run the script for security purposes.  Lastly, you will also need to run powershell as an administrator if you have UAC turned on because this script has to add files to the installation folder of your vSphere client.</p>
<div id="attachment_124" class="wp-caption alignnone" style="width: 421px"><a href="http://www.tinyint.com/wp-content/uploads/2009/09/launch-powershell.png"><img class="size-full wp-image-124" title="Launch Powershell as Administrator" src="http://www.tinyint.com/wp-content/uploads/2009/09/launch-powershell.png" alt="Launch Powershell as Administrator" width="411" height="599" /></a><p class="wp-caption-text">Launch Powershell as Administrator</p></div>
<p>Once you have powershell running as an administrator and change the execution policy, it is a simple process to run this script, simply CD to the folder that you have extracted the script, and run it by typing “.Windows7vSphere.ps1” and it will do the work of copying over the System.dll and creating the necessary files to launch vSphere client in development mode so it can use the System.dll.</p>
<div id="attachment_125" class="wp-caption alignnone" style="width: 543px"><a href="http://www.tinyint.com/wp-content/uploads/2009/09/powershell-commands.png"><img class="size-full wp-image-125" title="Execute Windows7vSphere.ps1" src="http://www.tinyint.com/wp-content/uploads/2009/09/powershell-commands.png" alt="Execute Windows7vSphere.ps1" width="533" height="438" /></a><p class="wp-caption-text">Change execution policy and execute Windows7vSphere.ps1</p></div>
<p>You should now have an icon on your desktop called “VMware vSphere Client (Windows 7)” which you then simply run as administrator to launch the vSphere client.  The reason you have to launch it as administrator is because it creates an environment variable that lets the vSphere client know that you are giving it a different System.dll to work with.  This is something also discussed in detail in the thread over at VMware Communities.</p>
<p>For anyone interested in powershell, this script also shows a few cool things such as reading from the <a href="http://technet.microsoft.com/en-us/library/dd315408.aspx">registry</a>, writing to an <a href="http://msdn.microsoft.com/en-us/library/system.xml%28VS.85%29.aspx">xml</a> document, as well as creating a windows <a href="http://msdn.microsoft.com/en-us/library/xsy6k3ys%28VS.85%29.aspx">shortcut</a> using pretty simple commands.</p>
<p>Hopefully this will help a few people streamline the process of getting the vSphere client installed on your Windows 7 machines.  If you notice any problems with the script, feel free to comment and let me know and I&#8217;ll try to fix it as soon as possible.</p>
<p><strong>Download the script and the dll needed here:</strong> <strong><a href="http://www.tinyint.com/wp-content/plugins/download-monitor/download.php?id=1"><img alt="Download Windows7vSphere.zip" border="0" src="/images/download.png" style="width: 48px; height: 48px; border-width: 0pt; border-style: solid; vertical-align: middle;" title="Download Windows7vSphere.zip" /><span style="font-size:14px;">Download Windows7vSphere.zip</span></a></strong><br /><br /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2009/09/04/vsphere-client-on-windows-7/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>401 Error on HttpWebRequest with NTLM Authentication</title>
		<link>http://www.tinyint.com/index.php/2009/08/24/401-error-on-httpwebrequest-with-ntlm-authentication/</link>
		<comments>http://www.tinyint.com/index.php/2009/08/24/401-error-on-httpwebrequest-with-ntlm-authentication/#comments</comments>
		<pubDate>Tue, 25 Aug 2009 00:05:44 +0000</pubDate>
		<dc:creator>tcnolan</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[401 error]]></category>
		<category><![CDATA[authentication]]></category>
		<category><![CDATA[iis7]]></category>
		<category><![CDATA[ntlm]]></category>
		<category><![CDATA[webrequest]]></category>

		<guid isPermaLink="false">http://www.tinyint.com/?p=109</guid>
		<description><![CDATA[Due to a security update to SMB that fixes a remote code execution vulnerability, you may experience 401.1 or 401.2 errors in certain situations while performing a WebRequest to one of your servers. This is because part of the security update institutes a loopback check on the authentication requests to prevent replay attacks. The Microsoft [...]]]></description>
			<content:encoded><![CDATA[<p>Due to a <a href="http://support.microsoft.com/kb/957097">security update</a> to SMB that fixes a remote code execution vulnerability, you may experience 401.1 or 401.2 errors in certain situations while performing a WebRequest to one of your servers.  This is because part of the security update institutes a loopback check on the authentication requests to prevent replay attacks.  The Microsoft KB article refers to a few different scenarios where you can see authentication problems after applying this patch, but the one I’m most interested in is when you start getting 401 errors after an HttpWebRequest on an ASP.Net page.</p>
<p>The issues I experienced were while creating a page to display general status of one of my companies Sharepoint servers.  The main issue which is the meat of this article was when I switched the authentication over to use NTLM instead of Digest, which broke my script.  Everything I had in place should have worked, but the previously mentioned security update slipped under the radar and it took a while to figure out what was going on.  You can do a basic web request on a server with Basic authentication by doing the following:</p>
<pre class="brush: vb; title: ; notranslate">Dim _response As String
Dim _auth As String = &quot;Basic&quot;
Dim _uri As Uri = New Uri(&quot;http://my.domain.local/my-page.aspx&quot;)
Dim _req As HttpWebRequest = WebRequest.Create(_uri)
Dim _cc As CredentialCache = New CredentialCache()
Dim _res As HttpWebResponse
Dim _sr As StreamReader

_cc.Add(_uri, _auth, New NetworkCredential(&quot;username&quot;, &quot;password&quot;, &quot;domain&quot;))
_req.PreAuthenticate = True
_req.Credentials = _cc.GetCredential(_uri, _auth)
_res = _req.GetResponse
_sr = New StreamReader(_res.GetResponseStream)
_response = _sr.ReadToEnd
_sr.Close()</pre>
<p><span id="more-109"></span><br />
That code works perfectly well with Basic and even Digest(if you change the _auth value) authentication, however it will most likely not work for you if you are using NTLM authentication and your server has had the <a href="http://support.microsoft.com/kb/957097">MS08-068 patch</a> applied to it.  Prior to discovering the conflict with this patch I went through a lot of effort to investigate the issue.  One of the most useful debugging utilities in IIS7 is the failed request tracing logs.  These logs give you really great insight as to what is going on inside your web request traffic.  You can also use a tool like Fiddler to try and see what’s happening, but unfortunately because our Sharepoint server was live, it would have caused SSL certificate issues if I put it in the mix in my situation.</p>
<p>After looking at the failed request traces logs, I noticed an interesting difference between one of the failed requests from my health check script and a purposely failed request through a web browser that I pointed to a file I had no access to read.</p>
<p><strong>401.3 Error message &#8211; Unauthorized due to ACL on resource</strong></p>
<p><a href="http://www.tinyint.com/wp-content/uploads/2009/08/401_3.png"><img class="alignnone size-full wp-image-110 mceItem" title="401_3" src="http://www.tinyint.com/wp-content/uploads/2009/08/401_3.png" alt="401_3" width="579" height="427" /></a></p>
<p><strong>401.2 Error message &#8211; Logon failed due to server configuration</strong></p>
<p><a href="http://www.tinyint.com/wp-content/uploads/2009/08/401_2.png"><img class="alignnone size-full wp-image-111 mceItem" title="401_2" src="http://www.tinyint.com/wp-content/uploads/2009/08/401_2.png" alt="401_2" width="575" height="252" /></a></p>
<p><strong>Note: </strong>Check out <a href="http://support.microsoft.com/kb/943891">http://support.microsoft.com/kb/943891</a> for all the status codes in IIS7</p>
<p>The difference here is that on the WebRequest, it wasn’t even getting an NTLM token from the .Net app.  This lead me astray however and made me think that there was a problem with the pre-authentication of the credentials as well as whether I was missing something in the web.config, or even if it was some unique problem with Sharepoint.  After a lot of investigation I discovered the Microsoft KB article titled: “<a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;896861">You receive error 401.1 when you browse a Web site that uses Integrated Authentication and is hosted on IIS 5.1 or IIS 6</a>”  After giving a thorough read of that document I realized the problem, Microsoft forgot to update the title of the KB article.  The sub status code I was getting on the 401 errors is different than Microsoft mentions in the article, and while they don’t mention IIS 7 in the article’s title, it does show up in the applies to section.</p>
<p>Since Microsoft recommends you leave the loopback check in place because it is part of the security update, I followed their recommended method of adding in a specified host name to the BackConnectionHostNames key in the registry.</p>
<p>As always, make registry modifications at your own risk, Microsoft always recommends you make a backup before making any modifications, check out the following KB article for backup instructions: <a href="http://support.microsoft.com/kb/322756">http://support.microsoft.com/kb/322756</a></p>
<blockquote><p><strong>Warning</strong> Serious problems might occur if you modify the registry incorrectly by using Registry Editor or by using another method. These problems might require that you reinstall the operating system. TinyInt.Com cannot guarantee that these problems can be solved. Modify the registry at your own risk.</p></blockquote>
<blockquote><p>To specify the host names that are mapped to the loopback address and can connect to Web sites on your computer, follow these steps:</p>
<ol style="margin-top: 0in;" type="1">
<li>Click <strong>Start</strong>,      click <strong>Run</strong>, type regedit, and then click <strong>OK</strong>.</li>
<li>In Registry Editor,      locate and then click the following registry key:</li>
</ol>
<p style="padding-left: 60px;"><strong>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Lsa\MSV1_0</strong></p>
<ol style="margin-top: 0in;" type="1">
<li>Right-click <strong>MSV1_0</strong>,      point to <strong>New</strong>, and then click <strong>Multi-String Value</strong>.</li>
<li>Type      BackConnectionHostNames, and then press ENTER.</li>
<li>Right-click <strong>BackConnectionHostNames</strong>,      and then click <strong>Modify</strong>.</li>
<li>In the <strong>Value data</strong> box, type the host name or the host names for the sites that are on the      local computer, and then click <strong>OK</strong>.</li>
<li>Quit Registry Editor,      and then restart the IISAdmin service.</li>
</ol>
</blockquote>
<p>Now that you have taken care of editing the registry to include the hostname you are using in your code, you should be able to make your WebRequest over NTLM without a problem, just make sure you have impersonate=”true” in your web.config file.</p>
<p>Attached below is the code for the health check script that I have been talking about throughout this article.  As I mentioned earlier, it does some very basic checks on the server just to see if things are running smoothly.  To use it you would simply need to change the variables being passed into the various functions to check your database connectivity.  We use WhatsUp Gold to track the value of ALL_STATUS_OK to make sure things are working properly, and once one of the values fails it sends us an alert.  Another thing to keep in mind is if you are using the WebRequest piece in this code, make sure you grant the user you are authenticating as access to the Sharepoint page you are checking.  Lastly, if you use the code, make sure you read the comment in the web.config file about encrypting the settings so your password is not exposed, even if you are using a low privileged user account.</p>
<p>Download Source: <strong><a href="http://www.tinyint.com/wp-content/plugins/download-monitor/download.php?id=2"><img alt="Download sharepoint-contentscan.zip" border="0" src="/images/download.png" style="width: 48px; height: 48px; border-width: 0pt; border-style: solid; vertical-align: middle;" title="Download sharepoint-contentscan.zip" /><span style="font-size:14px;">Download sharepoint-contentscan.zip</span></a></strong><br /><br /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tinyint.com/index.php/2009/08/24/401-error-on-httpwebrequest-with-ntlm-authentication/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
