<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Business and Information Technology Tangents</title>
	<atom:link href="http://bittangents.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://bittangents.com</link>
	<description>Business and Information Technology Tangents is dedicated to providing quality content while informing the world about technology.</description>
	<lastBuildDate>Wed, 04 Jan 2012 17:37:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='bittangents.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Business and Information Technology Tangents</title>
		<link>http://bittangents.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://bittangents.com/osd.xml" title="Business and Information Technology Tangents" />
	<atom:link rel='hub' href='http://bittangents.com/?pushpress=hub'/>
		<item>
		<title>PowerShell queryService&#8211;Wait for a Dependency Starting Service</title>
		<link>http://bittangents.com/2011/06/03/powershell-queryservicewait-for-a-dependency-starting-service/</link>
		<comments>http://bittangents.com/2011/06/03/powershell-queryservicewait-for-a-dependency-starting-service/#comments</comments>
		<pubDate>Fri, 03 Jun 2011 01:13:42 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Powershell Tangents]]></category>
		<category><![CDATA[powershell]]></category>
		<category><![CDATA[query]]></category>
		<category><![CDATA[service]]></category>
		<category><![CDATA[start]]></category>
		<category><![CDATA[status]]></category>
		<category><![CDATA[wait]]></category>

		<guid isPermaLink="false">https://brentblawat.wordpress.com/2011/06/03/powershell-queryservicewait-for-a-dependency-starting-service/</guid>
		<description><![CDATA[By: Brenton Blawat There have been several occasions while scripting in PowerShell that the script is dependent on a specific service in the running state. A good example is the need to wait for the WMI Service to startup prior to making a WMI call, or SQL Server where when you restart the services, you [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=516&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>By: Brenton Blawat</strong></p>
<p>There have been several occasions while scripting in PowerShell that the script is dependent on a specific service in the running state. A good example is the need to wait for the WMI Service to startup prior to making a WMI call, or SQL Server where when you restart the services, you have to wait for the services to be in a running state before you can execute commands.</p>
<p>The following function solves this issue. It also displays the proper implementation of a PowerShell wait timer to wait for a service to become operational before continuing in the script.</p>
<h2>PowerShell Code Waiting for Service</h2>
<p><a href="http://www.brentblawat.com/blog/codesnippets/QueryService.ps1"><strong>Download Code</strong></a></p>
<p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#039;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># This Function Will Query A Dependancy Service and wait until the timer expires OR for the service to start.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> <span style="color:#0000ff;">function</span> QueryService { <span style="color:#0000ff;">param</span>($Service,$timer1)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>     $success = <span style="color:#006080;">&quot;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span>     write-host <span style="color:#006080;">&quot;Waiting on $Service Service...&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span>     </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>     <span style="color:#008000;"># Create a for loop to INC a timer Every Second</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span>     <span style="color:#0000ff;">for</span> ($b=1; $b <span style="color:#cc6633;">-lt</span> $timer1; $b++) {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span>             $servicestat = get-service $Service</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span>             $status = $servicestat.status</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span>             $b2 = $timer1 - $b</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span>             <span style="color:#008000;"># Determine the Percent Complete for the seconds.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span>             $percent = $b * (100 / $timer1)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span>             </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span>             <span style="color:#008000;"># Display the progress on the Screen</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum16">  16:</span>             Write-Progress -Activity <span style="color:#006080;">&quot;Waiting on $Service Service...&quot;</span> -PercentComplete $percent -CurrentOperation <span style="color:#006080;">&quot;$b2 Seconds Remaining&quot;</span> -Status <span style="color:#006080;">&quot;Current WMI Status: $status&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum17">  17:</span>             </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum18">  18:</span>             <span style="color:#008000;"># Determine if the Process is Running. If not, reloop. If so exit loop.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum19">  19:</span>             <span style="color:#0000ff;">if</span> ($status <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">&quot;Running&quot;</span>) {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum20">  20:</span>                 write-host <span style="color:#006080;">&quot;$Service Service Started Successfully: $status in $b Seconds&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum21">  21:</span>                 [int]$b = $timer1    </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum22">  22:</span>                     $success = <span style="color:#006080;">&quot;yes&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum23">  23:</span>                 </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum24">  24:</span>                 <span style="color:#008000;"># Tells the Loop to Stop Incrementing as the Service is running</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum25">  25:</span>                 Write-Progress -Activity <span style="color:#006080;">&quot;Completed&quot;</span> -Status <span style="color:#006080;">&quot;Current $Service Status: $status in $b Seconds&quot;</span> -Completed </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum26">  26:</span>                 </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum27">  27:</span>             }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum28">  28:</span>         </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum29">  29:</span>         <span style="color:#008000;"># Start-Sleep is available for the write-progress. Its value is in seconds.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum30">  30:</span>         start-sleep 1</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum31">  31:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum32">  32:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum33">  33:</span>     <span style="color:#008000;"># The script will now stop as the above loop has meet its time criteria and the success is not set to yes.time has expired.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum34">  34:</span>     <span style="color:#0000ff;">if</span> ($success <span style="color:#cc6633;">-ne</span> <span style="color:#006080;">&quot;yes&quot;</span>) { </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum35">  35:</span>         write-host <span style="color:#006080;">&quot;ERROR in Script: $Service Service Did Not Start In $timer1 Seconds. Status: $status&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum36">  36:</span>         <span style="color:#008000;"># Stop the Script</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum37">  37:</span>        BREAK</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum38">  38:</span>     } </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum39">  39:</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum40">  40:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum41">  41:</span> <span style="color:#008000;"># The service must be the actual executible name, not the friendly name</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum42">  42:</span> <span style="color:#008000;"># The Below Examples are Querying SQL Services for startup waiting 120 seconds for a timeout.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum43">  43:</span> QueryService <span style="color:#006080;">&quot;SQLServerAgent&quot;</span> <span style="color:#006080;">&quot;120&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum44">  44:</span> QueryService <span style="color:#006080;">&quot;MSSQLSERVER&quot;</span> <span style="color:#006080;">&quot;120&quot;</span></pre>
<p><!--CRLF--></div>
</p></div>
</p>
<p>The implementation of the QueryService is pretty straight forward. The syntax is </p>
<p>QueryServices “EXENAME” “TIMEOUT_IN_SECONDS”</p>
<p>The exe name is what is found in the Services Management Console listed under the &quot;Service Name”. Using the “Display Name” will not work with this function.</p>
<p><strong>Please note:</strong> If a service is running, there will be approximately a second delay in the script while the system is verifying if the service is running. This is a small sacrifice for error handling in the instance that the service may not be running. </p>
<p>Happy Coding!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/516/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/516/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/516/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=516&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2011/06/03/powershell-queryservicewait-for-a-dependency-starting-service/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>
	</item>
		<item>
		<title>Verizon Wireless&#8211;4G LTE Technology / Sales Disconnection&#8211;Very Frustrating</title>
		<link>http://bittangents.com/2010/12/08/verizon-wireless4g-lte-technology-sales-disconnectionvery-frustrating/</link>
		<comments>http://bittangents.com/2010/12/08/verizon-wireless4g-lte-technology-sales-disconnectionvery-frustrating/#comments</comments>
		<pubDate>Wed, 08 Dec 2010 04:56:51 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Product Review Tangents]]></category>

		<guid isPermaLink="false">https://brentblawat.wordpress.com/2010/12/08/verizon-wireless4g-lte-technology-sales-disconnectionvery-frustrating/</guid>
		<description><![CDATA[By: Brenton Blawat Thinking about transitioning your 3G service to Verizon Wireless’s 4G LTE bandwagon? Read the article below! It could save you a lot of money. On December 5th, 2010, Verizon Wireless officially offered 4G LTE services for their customers. This new IP based technology, is noted to offer 10 times the speed from [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=506&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>By: Brenton Blawat</strong></p>
<p>Thinking about transitioning your 3G service to <a href="http://www.verizonwireless.com/4G" target="_blank">Verizon Wireless’s 4G LTE</a> bandwagon? <strong><u>Read the article below!</u> </strong>It could save you a lot of money. </p>
<p>On December 5th, 2010, Verizon Wireless officially offered 4G LTE services for their customers. This new IP based technology, is noted to offer 10 times the speed from the 3G technology and be the most advanced 4G network yet. With new devices in the store to prove the speed, and truly a noticeable difference in the speeds, it would make any techy guy curious to upgrade to this new technology. Both devices released by Verizon Wireless run around $99.00 online and $149.00 with $50.00 mail-in rebate in the store. The cost is not significant enough to be afraid of and sparked my interest enough to purchase a device.</p>
<p>I had been using a <a href="http://www.evdoinfo.com/content/view/2597/64/" target="_blank">Novatel Wireless USB760 3G device</a> for VPN into my office and listening to Pandora. It did everything I needed including hosting Citrix sessions to DOORS (Dynamic Object-Oriented Requirements), submitting code changes to Rational Clear Case, and Remote Desktop Connections, all with VERY little lag. For businesses purposes, the 3G device works just fine in good coverage. I especially appreciated Verizon Wireless’s (almost) seamless network and traveling between the states, I almost never have an issue with coverage. I have been (and still very much am) a very happy customer with Verizon Wireless.</p>
<p>Since I recently moved to a place located in <a href="http://www.EdenPrairie.org" target="_blank">Eden Prairie, MN</a>, and started work in <a href="http://www.minneapolis.com/" target="_blank">Minneapolis, MN</a>, it became an immediate no brainer to switch to the 4G service. That way I would completely avoid having to wait for <a href="http://www.qwest.com" target="_blank">Qwest</a> or <a href="http://www.comcast.com" target="_blank">Comcast</a> to deliver a cable modem to setup my new place with internet. I could really capitalize on my use of my broadband card since I barely hit the limit every month with the 3G services. After all, I was in the market for broadband service for my new place, and FiOS was not available in this market. I found my way into purchasing a <a href="http://www.unwiredview.com/2010/12/04/verizons-pantech-uml290-4g-lte-modem-available-tomorrow-too/" target="_blank">Pantech UML 290</a> featuring Verizon’s 4G service. Through a bit of upgrading of my account, and keeping my 5GB data plan for $59.99, I became a proud father of the 4G device and services.</p>
<p>The second I got home, I whipped out the card, ignoring the “big red warning on the box”&#160; (telling me to install the updated VZ Access Manager) and plugged in into my laptop to find a frustrating point. The Pantech UML 290, does not include in the driver updates on the device like my Novatel Wireless Device did. In the past, I would just plug the Novatel device into a computer and there was a sector on the Novatel device that had a version of the VZ Access Manager. With the Pantech device I had to install it from a CD; I can’t imagine if were to lose this CD. I’d say I’m most disappointed because the VZ Access Manager did not receive and update to have these drivers included by default, therefore, I had to install the updated software on two of my laptops and my workstation &#8212; <strong>I am NOT a fan of this</strong>.</p>
<p>After getting past the 2 minute installation – not that much of a pain point – I immediately logged into my <a href="http://www.netflix.com/" target="_blank">NetFlix</a> account and browsed for movies to test video streaming capabilities. This had been a pain point of my 3G card where steaming video could be challenging. Looking to unpack stuff and watch a movie I settled on the <a href="http://www.imdb.com/title/tt0258463/" target="_blank">Bourne Identity</a> and hit play. The video quality was great and there were absolutely NO hiccups with the service. To test the buffering, I decided to pause the video, fast forward it and resume play. Within a second or two, the video started to play again. From there I let the 119minute video play to the credits. After the Bourne Identity, I went on <a href="http://www.hulu.com" target="_blank">Hulu</a> and found my guilty pleasure of <a href="http://www.fox.com/hellskitchen/" target="_blank">Hells Kitchen</a>, a 45 minute video stream. Again, a flawless stream. From that point, I was extremely excited to brag to all my co-workers about the new 4G toy that I got, certain all of them would transition their services over. </p>
<h2>Where The Dollars Don’t Make Sense</h2>
<p>Curious to see what type of bandwidth I was using streaming the video from NetFlix and Hulu, I took a look at my data usage keeping in mind, I already used 600MB of bandwidth. This is about where Verizon Wireless lost my interest to continue the 4G services. </p>
<p>&#160;<br />
<table border="0" cellspacing="0" cellpadding="0" width="800">
<tbody>
<tr>
<td valign="top" width="400">
<p align="center"><a href="http://brentblawat.files.wordpress.com/2010/12/img_20101207_211856.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:inline;border-top:0;border-right:0;padding-top:0;margin:0;" title="IMG_20101207_211856" border="0" alt="IMG_20101207_211856" src="http://brentblawat.files.wordpress.com/2010/12/img_20101207_211856_thumb.jpg?w=183&#038;h=244" width="183" height="244" /></a></p>
</td>
<td valign="top" width="400"><a href="http://brentblawat.files.wordpress.com/2010/12/img_20101207_211920.jpg"><img style="background-image:none;border-bottom:0;border-left:0;padding-left:0;padding-right:0;display:block;float:none;margin-left:auto;border-top:0;margin-right:auto;border-right:0;padding-top:0;" title="IMG_20101207_211920" border="0" alt="IMG_20101207_211920" src="http://brentblawat.files.wordpress.com/2010/12/img_20101207_211920_thumb.jpg?w=375&#038;h=281" width="375" height="281" /></a></td>
</tr>
</tbody>
</table>
<p>In their “Your Guide” booklet shown above, the video streaming is rated at 260MB/hour standard definition (Bourne Identity is not available in HD streaming on NetFlix / and I can’t imagine Hells Kitchen is streamed in HD to a standard user). Since I was watching movies for about <strong>164 minutes</strong>, or <strong>2.73 hours</strong>, according to Verizon’s specifications, I would have racked up <strong>780 MB </strong>of data usage. Instead, I found that my <strong>600MB </strong>use that I already used got bumped up to <strong>2,300MB. </strong>This means that 2.73 hours of video cost me <strong>1700 MB which is a rate of <font color="#ff0000">622.7MB/HR</font>!!! </strong>Verizon Wireless missed their estimated use by almost 3 times their printed data rate.</p>
<p><strong>Why such a difference from my 3G?</strong> Well, video sites such as Hulu, NetFlix, and YouTube have new bandwidth specific buffering technologies. In essence, if you have a slow connection, it will lower the quality of the video you see. This equates to a lower bandwidth requirement. So technically, the documentation is correct for <strong>3G broadband cards</strong>. Likewise, for <strong>4G Broadband Cards</strong> that can support higher bandwidth rates, the requirement will be greater. This also applies to audio streaming sites such as <a href="http://www.pandora.com" target="_blank">Pandora</a>. The audio quality gets lowered and increased depending on what type of connection you have.</p>
<h2>Warning! DO NOT WATCH VIDEO ON THE 4G NETWORK!! (until data plans change)</h2>
<p>For any user that unchecked viewing the data usage, and would watch at least 2.73 hours of TV a night, they would reach their daily limit of <strong>5GB</strong> in <strong>3 days</strong> and <strong>10GB</strong> in <strong>6 days</strong>. Now, for 10GB customers that continue at that data usage rate for the whole month (lets say its February) for 28 days, they would use <strong>47.6GB </strong>of data. The overage per GB / month rate is $10/GB, the unsuspecting Verizon Wireless Customer will rack up <font color="#ff0000"><strong>$380 access overage charges </strong></font>in addition to their $80.00 plan. One month of minor video use on the plan will run <font color="#ff0000"><strong>$460.00 for a month! </strong></font><font color="#000000">I can’t even imagine if I were to fall asleep one night streaming Hulu or watching the notoriously long Lord of the Rings Video series, and 8 hours later have all my data plan used. It would cost more than 90% of the hotels I’ve been in for a night. Ouch.</font></p>
<p>This is a major oversight by the Verizon Wireless sales and marketing team. It goes in line of the age old saying of what Intel “Give-ith”, Microsoft “Take-ith”. Giving your customers more through-put will promote higher data utilization. I would personally be willing to pay $120/month for unlimited data usage on a 4G network with the ability to go to use the 3G markets where 4G is not supported (all the Verizon Wireless Cards are backwards compatible with 3G). It is, however, not the case, and I wrote this article to gain support from my community to ask Verizon Wireless to bump up their data usage. </p>
<h2>The Final Verdict of 4G LTE</h2>
<p>The Verizon Wireless 4G LTE service is amazing in both Eden Prairie, MN and Minneapolis, MN. When streaming video, the video buffer was almost immediately full and browsing from site to site was equally as impressive. This completely destroys the 3G technologies and the 4G LTE want-to-be companies like Sprint and US Cellular. I want to be clear that I LOVE the new Verizon Wireless 4G technology and what it has to offer, but I strongly dislike the 4G pricing structure. I see Verizon Wireless as the Mercedes and BMW of the cellular networks, and I am willing to pay for every feature as long as it provides value and isn’t insanely priced. I currently pay $249.00/ month in smart phone, and broadband charges. I’m having a really difficult time justifying the benefit of 4G over a DSL / Cable / FiOS network with its pricing structure and how much I am paying right now. I am a <u><strong>premium home user</strong></u>.</p>
<p><strong>Why not stick with the 4G device?</strong> Well the problem is, you don’t get real time data usage notifications. You only get notified at the beginning of the data session of what your usage is. This means that if you are in a heavy data session, like getting carried away on YouTube, watching clips like <a href="http://www.youtube.com/watch?v=HE4FJL2IDEs" target="_blank">Charlie Bite me</a>, you might get a surprise in the mail at months end. Likewise if you’re a technician downloading an ISO, like to download music on iTunes, or need to restore your iTunes downloads; all data intensive items that would go quickly and would just as quickly take your money.</p>
<p><strong>Final Verdict – </strong>After using the device for <strong>less than 24 hours</strong> and a $<strong>35.00 “restocking” fee</strong>, I am back to my 3G Novatell Wireless Card. While I may be out $35.00, it could have been much, much more than that! Qwest internet installation has been scheduled and I am back posting blog articles using my Verizon Wireless Novatel 3G device.</p>
<p>I strongly encourage comments.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/506/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/506/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/506/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/506/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/506/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/506/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/506/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/506/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/506/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/506/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/506/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/506/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/506/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/506/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=506&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2010/12/08/verizon-wireless4g-lte-technology-sales-disconnectionvery-frustrating/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/12/img_20101207_211856_thumb.jpg" medium="image">
			<media:title type="html">IMG_20101207_211856</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/12/img_20101207_211920_thumb.jpg" medium="image">
			<media:title type="html">IMG_20101207_211920</media:title>
		</media:content>
	</item>
		<item>
		<title>SQL Server 2008 Security Permissions &#8211; Windows / Active Directory Authentication Issues</title>
		<link>http://bittangents.com/2010/10/04/sql-server-2008-security-permissions-windows-active-directory-authentication-issues/</link>
		<comments>http://bittangents.com/2010/10/04/sql-server-2008-security-permissions-windows-active-directory-authentication-issues/#comments</comments>
		<pubDate>Mon, 04 Oct 2010 22:51:44 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Software Tangents]]></category>

		<guid isPermaLink="false">https://brentblawat.wordpress.com/2010/10/04/sql-server-2008-security-permissions-windows-active-directory-authentication-issues/</guid>
		<description><![CDATA[By: Brenton Blawat Systems Administrators around the world have been baffled by security changes with SQL Server 2005/2008 and Active Directory Authentication. Even more so the issues with traversing through layers of security groups for Windows permissions within SQL Server 2008. For example, in the initial releases of SQL Server 2008, there was a frustrating [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=497&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>By: Brenton Blawat</strong></p>
<p>Systems Administrators around the world have been baffled by security changes with SQL Server 2005/2008 and Active Directory Authentication. Even more so the issues with traversing through layers of security groups for Windows permissions within SQL Server 2008. For example, in the initial releases of SQL Server 2008, there was a frustrating bug in which adding new domain users or groups to SQL Server 2008, you MUST add these domain users and groups as the <u><strong>user that installed </strong></u>SQL Server 2008; be it a domain or a local user. Below are two SQL Server Windows Security caveats that we found were necessary to address to provide some level of sanity to our readers.</p>
<h2>&#160;</h2>
<h2>User Security Identifiers Now in the Sys.SysLogins</h2>
<p>One item that Microsoft snuck into SQL Server 2005 and SQL Server 2008 are the use of Security Identifiers (SIDs) in the authentication model. In the typical model of SQL User Authentication, this becomes a non issue, however, with a Windows based authentication, this can cause <strong><u>HUGE </u></strong>headaches if not planned for properly.</p>
<p>Security Identifiers are identification GUIDs that are tied to users and groups in local security and active directory. These values are created to ensure that if a hacker tries to hijack a username such as “<strong>Brenton”</strong> in the “<strong>Geeks” </strong>group, it rejects the hijacked username as the security identifier is required in addition to the login name. This works as an excellent method to prevent hijacking attempts, however, if an administrator accidently deletes a User or Group, a new SID is created.</p>
<p>SIDs are secure but also are the key to the headache. Lets say a network consists of 1050 independent SQL Servers at a branch of retails stores, like <a href="http://www.ae.com" target="_blank">American Eagle Outfitters</a> (they really do have databases at each breach; and they really do have 1050+ stores). If the authentication credential on all 1050 stores is “<strong>Geek_User</strong>” and a systems administrator accidently deletes this user from Active Directory, all functionality under the “<strong>Geek_User</strong>” stops. When the systems administrator realizes that he deleted this user, he will add the user “<strong>Geek_User</strong>” back into Active Directory. The issue is that the &#8216;”<strong>Geek_User</strong>”, while named the same, has a new SID, and the authentication into SQL Server 2008 will still fail.</p>
<p>Further, this issue will be <strong><u>extremely difficult</u> </strong>to figure out because the User will exists within active director/local security and SQL Server. However, the authentication into SQL Server will fail to work and the services assigned to the authentication will fail to start.</p>
<p>*NOTE: SQL Server 2008 will not allow a User to start its services&#160; (E.G. SQL Server Agent), if the user does not have privileges within SQL Server 2008. The User or Group has to be added prior to the services starting.</p>
<p>One may experience an error message when starting the SQL Server Agent (being that the “<strong>Geeks_User</strong>” starts the service)<strong>&#160;</strong>:</p>
<p><a href="http://brentblawat.files.wordpress.com/2010/10/err1.jpg"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="err1" border="0" alt="err1" src="http://brentblawat.files.wordpress.com/2010/10/err1_thumb.jpg?w=432&#038;h=177" width="432" height="177" /></a> </p>
<blockquote><p>“Windows Could not start the SQL Server Agent (MSSQLSERVER) service on the Local Computer. </p>
<p>Error 1069: The Service did not start due to a logon failure.”</p>
</blockquote>
<p>In a panic, the Systems Administrator now goes into services and re-configures the SQL server credentials of the “<strong>Geek_User</strong>”. The system now provides the misleading message of granting the logon privilege to the “<strong>Geek_user</strong>”. Now that the Service Authentication has the correct SID the error message changes. When the systems administrator starts SQL Server Agent Service, the following message is splayed:</p>
<p><a href="http://brentblawat.files.wordpress.com/2010/10/err2.jpg"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="err2" border="0" alt="err2" src="http://brentblawat.files.wordpress.com/2010/10/err2_thumb.jpg?w=450&#038;h=168" width="450" height="168" /></a> </p>
<blockquote><p>“The SQL Server Agent (MSSQLSERVER) service on Local Computer started and then stopped. Some services stop automatically if they are not in use by other services or programs.”</p>
</blockquote>
<p>When the systems administrator checks the Windows Event Log it displays:</p>
<p>&quot;Login failed for user &#8216;%&#8217;. Reason: Token-based server access validation failed with an infrastructure error. Check for previous errors&quot;</p>
<h4>Correcting SID Issues</h4>
<p>All of the above error messages are examples of broken SID error messages. The <strong><u>only way to correct this issue is to remove and re-add the users and groups that have been accidently deleted</u></strong> in SQL Server 2008. This can be done in two different ways, one, a network script on all of the servers, that utilizes SQL Server Authentication or two, a remote Powershell script.</p>
<p>The way to prevent a global outage due to this issue on a global scale for the “large retailer” example, is to create individual Windows User credentials for each of their 1050 stores and place them within their respective SQL Server 2008 instance. This will provide the security of Active Directory (disabling a user account if the server is stolen), and the centralized management utilizing Active Directory. While adding a Group may seem like a more efficient methodology, and it is recommended by Microsoft, it still provides a single point of failure if the credentials are accidently deleted.</p>
<p>The following command can be executed to drop the “<strong>Geek_User</strong>” from SQL and re-creating the “<strong>Geek_User</strong>” with ‘<strong>sysadmin</strong>’ privileges:</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#039;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> <span style="color:#0000ff;">DROP</span> LOGIN [Geek_User]</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span> <span style="color:#0000ff;">CREATE</span> LOGIN [Geek_User] <span style="color:#0000ff;">FROM</span> WINDOWS <span style="color:#0000ff;">WITH</span> DEFAULT_DATABASE=[MASTER], DEFAULT_LANGUAGE=[us_english]</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span> <span style="color:#0000ff;">EXEC</span> sys.sp_addsrvrolemember @loginame = N<span style="color:#006080;">'Geek_User'</span>, @rolename = N<span style="color:#006080;">'sysadmin'</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>&#160; </pre>
<p><!--CRLF--></div>
</div>
<p>&#160;</p>
<p>If Powershell is your flavor of scripting, assuming you know the computer names of each store, the Powershell Code below can be added the “Powershell Script to Determine NetBIOS – Powershell to Add SQL Server 2008 Users or Groups” code (below). Execute these commands on all of the servers affected by the issue. </p>
<p>Feel free to contact me if you would like me to create a looping mechanism with a CSV import.</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#039;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># Add the user into SQL. Be sure to change the SQL User of sa and password of my password.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> [string]$err = sqlcmd -Usa -Pmypassword -d <span style="color:#006080;">'master'</span> -Q <span style="color:#006080;">&quot;DROP LOGON `[$user`]&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span> <span style="color:#008000;"># This variable will become populated if an error occurred; else it will remain blank.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span> <span style="color:#0000ff;">if</span> ($err) { write-host <span style="color:#006080;">&quot;ERROR! The following error occurred while Dropping SQL User from Master Database: $err &quot;</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>&#160;</p>
<h2>NetBIOS Based Windows Authentication Only</h2>
<p>One of the issues that we worked with Microsoft to resolve is the authentication mechanisms for users and groups in SQL Server 2008. As of October 4th, 2010, Microsoft <strong><u>only</u> </strong>supports NETBIOS based Windows authentication. This means that the credentials of “<strong>domain.root\Username</strong>” are NOT supported by the SQL Server 2008 authentication protocol stack. Further, in order to use complex domain structures such as “<strong>WinXPDevGrp.US.Microsoft.com</strong>”, it is <u><strong>required that an administrator resolves the NetBIOS name value of the domain</strong></u> prior to the addition of the User or Group. </p>
<p>Taking the above example, trying to resolve a group named “<strong>Geeks</strong>”, in the United States Windows XP Development Group at Microsoft, would fail if the administrator utilized the logon name of “<strong>WinXPDevGrp.US.Microsoft.com\Geeks</strong>”. The following error would appear: </p>
<p><a href="http://brentblawat.files.wordpress.com/2010/10/autherr.jpg"><img style="display:block;float:none;margin-left:auto;margin-right:auto;border-width:0;" title="AuthErr" border="0" alt="AuthErr" src="http://brentblawat.files.wordpress.com/2010/10/autherr_thumb.jpg?w=593&#038;h=193" width="593" height="193" /></a></p>
<blockquote>
<p>&#160;</p>
</blockquote>
<blockquote>
<p>“ Create Failed for Login ‘WINXPDEVGRP.US.MICROSOFT.COM\Geeks’. (Microsoft.SqlServer.Smo)</p>
<p>Additional Information:</p>
<p>|&#8211;&gt; An Exception occurred while executing a Transact-SQL statement or Batch. (Microsoft.SqlServer.ConnectionInfo)</p>
<p>|&#8212;&#8212;&#8212;&#8211;&gt; Windows NT user or group ‘WINXPDEVGRP.US.MICROSOFT.COM\Geeks’ not found. Check the name again. (Microsoft SQL Server, Error:15401) </p>
</blockquote>
<p>Given the conversations with Microsoft, it unfortunately is the character of ‘period’ in the authentication string that is causing the error above. After research, I found that Microsoft addressed the ‘period’ issue in the column names as found in <a href="http://support.microsoft.com/kb/972856/en-US" target="_blank">this knowledge base article: KB972856</a>. SQL Server 2008 does not like the use of Periods. Even when using brackets around the name shown like “<strong>[WinXPDevGrp.US.Microsoft.com\Geeks]</strong>” or “<strong>[WinXPDevGrp.US.Microsoft.com]\[Geeks]</strong>”, SQL Server 2008 will still produce the above error message.</p>
<h4>Workarounds for Domain Authentication</h4>
<p>No worries my friends, there are workarounds to this issue. At this point, you typically go to your Systems Administrator asking how to convert domain names to NetBIOS names. Or perhaps ask do all domains have NetBIOS Names? – The simple answer is No. NetBIOS Names are NOT required to create a domain on certain domain controllers. In fact, some organizations disable the use of NetBIOS. </p>
<p>Do all Microsoft Domains have NetBIOS Names? This is a little bit more of a complicated answer. When configuring Active Directory on a Windows Server 2008 Domain Controller, in order to support domain trusts, and forest trusts, Domain NetBIOS names are required. This is our speculation, but we assume this is why SQL Server 2008 utilizes NetBIOS Names for authentication. If the Domain NetBIOS Name cannot be resolved, it assumes either the NetBIOS resolution is disabled or the domain / forest trusts are not configured correctly.&#160;&#160; </p>
<p><strong>Workaround #1 –</strong> Using the Login Name: “Search…” Feature</p>
<p>SQL Server provides a mechanism for searching the domain for users. There are a few prerequisites that are required on both the SQL Server 2008 system. The following services are required for network browsing on Windows Server 2008 that has SQL Server 2008 on it:</p>
<ul>
<li>Computer Browser Service – Service Name: “Browser” </li>
<li>Function Discovery Provider Host – Service Name: “fdPHost” </li>
<li>SSDP Discovery Service – Service Name: “SSDPSRV” </li>
<li>UPnP Device Host Service – Service Name: “UPNPhost” </li>
<li>The firewall rule for network discovery must be configured to enabled utilizing the following command:
<ul>
<li>netsh advfirewall firewall set rule group=”Network Discovery” new enable=yes </li>
</ul>
</li>
</ul>
<p>From there, you can search the Active Directory Structure to find the appropriate user or group using the SQL Server 2008 GUI.</p>
<p><strong>Workaround #2 – </strong>Utilizing NBTSTAT to resolve Domain NetBIOS Names</p>
<p>The tool of choice for system administrators is NBTSTAT. Typing the following command will allow for Domain NetBIOS name Resolution of the current domain you are connected to on a system:</p>
<ul>
<li>nbtstat –n </li>
</ul>
<p>Command Result:</p>
<p align="center">NetBIOS Local Name Table</p>
<p align="center">NAME…………………TYPE …………………STATUS</p>
<p align="center">XPDEVGRP12…………UNIQUE …………………Registered</p>
<p align="left">&#160;</p>
<p align="left">The NetBIOS name of “<strong>XPDEVGRP12\Geeks</strong>” would then be required to be <u>manually</u> entered into the “Login Name:” field of the SQL Server GUI, or manually placed into the CREATE LOGON command.</p>
<p><strong>Workaround #3 </strong>– Automated Powershell Domain NetBIOS Name Resolution and User Creation</p>
<p>We couldn’t help with my utter (<a href="http://me.andering.com/wp-content/uploads/2006/05/moo.jpg" target="_blank">moo</a>) frustration with not being able to come up with a command within a SQL Query to resolve the Domain NetBIOS name without using “sp_configure XP_cmdshell”; a major NO NO for the <a href="http://www.defense.gov/" target="_blank">Department of Defense</a> regulatory security requirements. </p>
<p>Instead we developed a Powershell script to perform the following:</p>
<ul>
<li>Resolve the Domain NetBIOS Name </li>
<li>Create the User Syntax For the SQL CREATE LOGON Command </li>
<li>Issue SQLCMD commands to create the logon </li>
</ul>
<p>&#160;</p>
<h4>Powershell Script to Determine NetBIOS – Powershell to Add SQL Server 2008 Users or Groups</h4>
<p><a href="http://www.brentblawat.com/blog/codesnippets/NetBIOS_SQLUSER.ps1" target="_blank">Download PS1 Code Here</a></p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#039;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># This script will resolve the NetBios Name of a Domain then add a user with the netbios name.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> <span style="color:#008000;"># Don't forget to execute: set-executionpolicy RemoteSigned</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span> <span style="color:#008000;"># in powershell prior to the use of this script</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span> <span style="color:#008000;"># Step 1: Import The Active Directory Module</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span> import-module activedirectory</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span> <span style="color:#008000;"># Step 2: Save the Current Directory Identity into a variable (Replace Domain.root with your domain)</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span> $ident = get-addomain -identity domain.root -ErrorVariable Err -ErrorAction SilentlyContinue</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span> <span style="color:#008000;"># If there is an Error Stop and Report it &gt; Else Continue</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span> <span style="color:#0000ff;">if</span> ($err) { Write-Host <span style="color:#006080;">&quot;ERROR! The following error occurred while obtaining NetBIOS Name: $err&quot;</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span> <span style="color:#008000;"># Select the netbios name and put it into a string</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span> [string[$netbiosname = $ident.netbiosname</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum16">  16:</span> <span style="color:#008000;"># Setup User Variable for the add. Change Geeks to the user or Group you'd desire.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum17">  17:</span> $user = $netbiosname + <span style="color:#006080;">&quot;\Geeks&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum18">  18:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum19">  19:</span> <span style="color:#008000;"># Add the user into SQL. Be sure to change the SQL User of sa and password of my password.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum20">  20:</span> [string]$err = sqlcmd -Usa -Pmypassword -d <span style="color:#006080;">'master'</span> -Q <span style="color:#006080;">&quot;CREATE LOGIN `[$user`] FROM WINDOWS WITH DEFAULT_DATABASE=`[MASTER`], DEFAULT_LANGUAGE=`[us_english`]&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum21">  21:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum22">  22:</span> <span style="color:#008000;"># This variable will become populated if an error occurred; else it will remain blank.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum23">  23:</span> <span style="color:#0000ff;">if</span> ($err) { write-host <span style="color:#006080;">&quot;ERROR! The following error occurred while creating SQL User: $err &quot;</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum24">  24:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum25">  25:</span> <span style="color:#008000;"># The permission addition will execute if the above command was successful.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum26">  26:</span> Else {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum27">  27:</span>     <span style="color:#008000;"># Add the credential of Sysadmin to the users. This can be changed to any role. </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum28">  28:</span>     [string]$err = sqlcmd -Usa -Pmypassword -d <span style="color:#006080;">'master'</span> -Q <span style="color:#006080;">&quot;EXEC sys.sp_addsrvrolemember @loginame = N'$user', @rolename = N'sysadmin'&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum29">  29:</span>     <span style="color:#0000ff;">if</span> ($err) {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum30">  30:</span>         write-host <span style="color:#006080;">&quot;Error Assigning Permisssions to $user: $err&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum31">  31:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum32">  32:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p>&#160;</p>
<p>While Microsoft did document how to do resolve NetBIOS <a href="http://technet.microsoft.com/en-us/library/dd391931(WS.10).aspx" target="_blank">in the Microsoft Library</a>, they forgot a major line of code; which you see in line 5. You have to Import the Active Directory Module into Powershell, or else the command will not be recognized. I thought I would repost this code and provide it to my readers. </p>
<p>This should be a very simple, but useful gem of knowledge.</p>
<p>Happy coding!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/497/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/497/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/497/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=497&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2010/10/04/sql-server-2008-security-permissions-windows-active-directory-authentication-issues/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/10/err1_thumb.jpg" medium="image">
			<media:title type="html">err1</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/10/err2_thumb.jpg" medium="image">
			<media:title type="html">err2</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/10/autherr_thumb.jpg" medium="image">
			<media:title type="html">AuthErr</media:title>
		</media:content>
	</item>
		<item>
		<title>Nested User Groups (Groups in Groups) / Built-in Local Groups Issue</title>
		<link>http://bittangents.com/2010/07/13/nested-user-groups-groups-in-groups-built-in-local-groups-issue/</link>
		<comments>http://bittangents.com/2010/07/13/nested-user-groups-groups-in-groups-built-in-local-groups-issue/#comments</comments>
		<pubDate>Tue, 13 Jul 2010 21:19:35 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Server Tangents]]></category>

		<guid isPermaLink="false">https://brentblawat.wordpress.com/2010/07/13/nested-user-groups-groups-in-groups-built-in-local-groups-issue/</guid>
		<description><![CDATA[By: Brenton Blawat “Broken By Design” UPDATED! After hours of conference calls with Microsoft, and multiple tiers of support, we come to the conclusion that Nested Local Groups in Built-in Groups are “broken by design”. What does this really mean? When you nest a Local Group into a Built-in Local Group, the effective permission set [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=486&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>By: Brenton Blawat</strong></p>
<p><strong>“Broken By Design”</strong></p>
<p><strong>UPDATED!</strong> After hours of conference calls with Microsoft, and multiple tiers of support, we come to the conclusion that Nested Local Groups in Built-in Groups are “broken by design”. What does this really mean? When you nest a Local Group into a Built-in Local Group, the effective permission set for the Users within that Local Group is reduced to <strong>Guest</strong>.<strong> </strong>This remains true unless the Users are specifically added into the Built-in Local Groups, which will result in proper permissions being passed to the Users. </p>
<p>&#160;</p>
<h2>Nesting Issue Explained</h2>
<p><a href="http://brentblawat.files.wordpress.com/2010/07/coregroups_small.jpg"><img style="display:inline;border-width:0;" title="coregroups_small" border="0" alt="coregroups_small" src="http://brentblawat.files.wordpress.com/2010/07/coregroups_small_thumb.jpg?w=410&#038;h=297" width="410" height="297" /></a> </p>
<p>Lets take the above graphic, where we created a new local group called ‘Geeks’ which contains users named “Brenton B” and “Jason P”. From there, we added the ‘Geeks’ local to the Built-in ‘Administrators’ local group. From that hierarchy, we should assume any users in the ‘Geeks’ Local Group, should obtain Administrative privileges by traversing through the security pathway. Unfortunately, this is <em>not</em> the case.</p>
<p>Note: This issue is for all of the <strong>Built-in</strong> Groups on the system including, but not limited to, Administrators, Backup Operators, Power Users, and Users. I used the Administrators Group, as it’s easiest to work with.</p>
<p>&#160;</p>
<p><a href="http://brentblawat.files.wordpress.com/2010/07/coregroupserr_fulljpg.jpg"><img style="display:inline;border-width:0;" title="coregroupserr_fulljpg" border="0" alt="coregroupserr_fulljpg" src="http://brentblawat.files.wordpress.com/2010/07/coregroupserr_fulljpg_thumb.jpg?w=451&#038;h=323" width="451" height="323" /></a> </p>
<p>The issue has to do with second level security traversing with Built-in Groups. While the first level traversing is a trusted security relationship in the operating system, the second security relationship is not trusted. This means that the ’Geeks’ Local Group object is effectively a member of the ‘Administrators’ Group and it also means that Brenton B. and Jason P. are members of the ‘Geeks’ Local Group. It will not, however, traverse to the second level and grant Brenton B. and Jason P. group membership to Administrators.</p>
<h2>&#160;</h2>
<h2>What About Restricted Groups in Group Policies?</h2>
<p>&#160;</p>
<p><a href="http://brentblawat.files.wordpress.com/2010/07/restrictedlocation.jpg"><img style="display:inline;margin-left:0;margin-right:0;border-width:0;" title="RestrictedLocation" border="0" alt="RestrictedLocation" align="left" src="http://brentblawat.files.wordpress.com/2010/07/restrictedlocation_thumb.jpg?w=239&#038;h=223" width="239" height="223" /></a> </p>
<p><a href="http://brentblawat.files.wordpress.com/2010/07/groupadded.jpg"><img style="display:inline;border-width:0;" title="groupadded" border="0" alt="groupadded" src="http://brentblawat.files.wordpress.com/2010/07/groupadded_thumb.jpg?w=714&#038;h=77" width="714" height="77" /></a>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>&#160;</p>
<p>This issue unfortunately is also present when you have Restricted Groups. <em>Restricted Groups </em>within Group Policies force group associations to the local groups in the Operating System. While you mandate the ‘TestAdmin’ Group as part of the Built-in Administrators Local Group, the permission lookup occurs on the Windows Operating System; thus the Nested Groups do not traverse.</p>
<h2>Can You Still Add Groups To Built-in Groups?</h2>
<p><a href="http://brentblawat.files.wordpress.com/2010/07/groups.jpg"><img style="display:inline;" title="groups" alt="groups" src="http://brentblawat.files.wordpress.com/2010/07/groups_thumb.jpg?w=425&#038;h=368" width="425" height="368" /></a> </p>
<p>Yes, as shown above! While the GUI of Windows does not provide a method to directly add Groups within Built-in Groups, you can execute two commands that would provide for adding Groups in Groups.</p>
<p>Method 1 – Powershell</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#039;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># Obtain the Current Computer Name</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> $cmpName = [System.Net.DNS]::GetHostName()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span> <span style="color:#008000;"># Make the ADSI Call into the Computer</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span> $adsiCall = [ADSI] (<span style="color:#006080;">&quot;WinNT://$cmpName,computer&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span> <span style="color:#008000;"># Create the worker variable</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span> $objworker = $adsiCall.Create(<span style="color:#006080;">&quot;group&quot;</span>,<span style="color:#006080;">&quot;Geeks&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span> $objworker.put(<span style="color:#006080;">&quot;description&quot;</span>,<span style="color:#006080;">&quot;Geeks Local Group&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span> <span style="color:#008000;"># Create Object from worker variable</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span> $objworker.setinfo()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span> <span style="color:#008000;"># Create the Group Association</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span> $adsistring = <span style="color:#006080;">&quot;$cmpName/Administrators,group&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum16">  16:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum17">  17:</span> <span style="color:#008000;"># Create the worker variable</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum18">  18:</span> $group = [adsi] (<span style="color:#006080;">&quot;WinNT://$adsistring&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum19">  19:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum20">  20:</span> <span style="color:#008000;"># Add the group</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum21">  21:</span> $group.add(<span style="color:#006080;">&quot;WinNT://$cmpName/Geeks&quot;</span>)</pre>
<p><!--CRLF--></div>
</div>
<p>Method 2 – NET Commands in BAT File</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#039;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> net localgroup <span style="color:#006080;">&quot;Geeks&quot;</span> /Add</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> net localgroup <span style="color:#006080;">&quot;Administrators&quot;</span> <span style="color:#006080;">&quot;Geeks&quot;</span> /Add</pre>
<p><!--CRLF--></div>
</div>
<p>* The above Methods add the ‘Geeks’ local Group, then add the ‘Geeks’ Local Group to the ‘Administrators’ Group</p>
<h2>&#160;</h2>
<h2>Resolution to the Issue</h2>
<p>The following can be performed to resolve the issue:</p>
<p>#1 Add the Users of the Geeks Group directly to the Built-in Administrators Group.</p>
<p>#2 Create a Domain Global Group named ‘Geeks’ and place the Domain Global Group ‘Geeks’ in the Local Administrators Restricted Group.</p>
<p>Supporting documents: According to Microsoft’s knowledge Base articles</p>
<p><a href="http://technet.microsoft.com/en-us/library/ee681621(WS.10).aspx">http://technet.microsoft.com/en-us/library/ee681621(WS.10).aspx</a> … “This is the expected behavior of the <strong>Computer Management</strong> snap-in.”</p>
<p>and</p>
<p><a href="http://support.microsoft.com/kb/974815">http://support.microsoft.com/kb/974815</a> … where we can quote directly “This behavior is by design. Windows does not support the nesting of local groups on domain clients or on workgroup clients.”</p>
<p>&#160;</p>
<p><strong>UPDATED! </strong>Let me explain this one a bit more – I received an email From Microsoft that explained the nesting functionality as follows:</p>
<blockquote>
<p>“The process of determining the security-groups a user belongs to is called group expansion, which is an integral part of user authentication. It is necessary that the group expansion accurately generates a list containing the groups that the user is a member of (directly or indirectly) in order to allow the user accesses to various resources. It is by design that group membership does not expand nested local groups.</p>
<p>Microsoft’s intention was to disallow nesting groups in group authoring experience (as in the case of the UI) to accurately reflect group expansion constraints. As your examples point out, there are several ways of nesting local groups, contrary to our intention. Our suggestion is to never nest local groups even when it is allowed by a group authoring tool like “net local group” because such nesting doesn’t reflect the group expansion constraints and the end results would be different from the expected results.”</p>
</blockquote>
<p>What Microsoft is saying in a formal way – Their design for group expansion model does not include the ability to look through multiple levels of local Nested Groups. It only provides the ability to look one level deep due to the way it was developed by Microsoft. By not knowing how large of an impact it would be to add the ability to nest local groups, I can only assume that Microsoft does not think it is advantageous to add this functionality due to the number of users that will be using the system in this way – which makes sense.</p>
<p>We were able to get the Local Groups to Accept “Global” and “Domain Local”* active directory groups. While this doesn’t help a stand alone system for nesting of groups, it does provide a work around for authentication. This means that if you were to make the ‘Geeks’ Group, from the first example above, a Active Directory Group, the local system will pass the authentication query to Active Directory which then has the mechanisms to traverse through nested groups.</p>
<p>** Be cautious when adding Domain Local Groups to the system as if you have any forests, or trusts, the security will not traverse through the forest or any trusts. ** </p>
<p>A special thanks to Jim Tan, Richard Leung, and Sunil Naik from Microsoft with their help on my issue!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/486/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/486/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/486/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/486/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/486/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/486/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/486/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/486/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/486/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/486/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/486/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/486/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/486/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/486/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=486&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2010/07/13/nested-user-groups-groups-in-groups-built-in-local-groups-issue/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/07/coregroups_small_thumb.jpg" medium="image">
			<media:title type="html">coregroups_small</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/07/coregroupserr_fulljpg_thumb.jpg" medium="image">
			<media:title type="html">coregroupserr_fulljpg</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/07/restrictedlocation_thumb.jpg" medium="image">
			<media:title type="html">RestrictedLocation</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/07/groupadded_thumb.jpg" medium="image">
			<media:title type="html">groupadded</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/07/groups_thumb.jpg" medium="image">
			<media:title type="html">groups</media:title>
		</media:content>
	</item>
		<item>
		<title>Powershell Import-GPO : The Data Is Invalid Fixed</title>
		<link>http://bittangents.com/2010/04/20/powershell-import-gpo-the-data-is-invalid-fixed/</link>
		<comments>http://bittangents.com/2010/04/20/powershell-import-gpo-the-data-is-invalid-fixed/#comments</comments>
		<pubDate>Tue, 20 Apr 2010 20:05:51 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Powershell Tangents]]></category>

		<guid isPermaLink="false">http://brentblawat.wordpress.com/2010/04/20/powershell-import-gpo-the-data-is-invalid-fixed/</guid>
		<description><![CDATA[By: Brenton Blawat This article is to aid those who are receiving the “Data is Invalid” error message in Powershell on Windows Server 2008 R2. This issue occurs while trying to import policies from one domain into their a different domain using a migration table. This issue has to do with the migration table editor [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=471&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>By: Brenton Blawat</strong></p>
<p>This article is to aid those who are receiving the “Data is Invalid” error message in Powershell on Windows Server 2008 R2. This issue occurs while trying to import policies from one domain into their a different domain using a migration table. This issue has to do with the migration table editor referring to the “Pre-Windows 2000 Username” to migrate users instead of their Standard Username.</p>
<p><strong>Syntax of Command Used for Error:</strong></p>
<blockquote><p>Import-GPO –BackupID {GUIDGOESHERE} –TargetName “Default_AccountingPolicy” –path “c:\scriptloc\” –MigrationTable “C:\scriptloc\DefaultMig.migtable” –CreateIfNeeded | Out-Null</p>
</blockquote>
<p><strong>Error:</strong></p>
<blockquote><p>“ Import-GPO : The Data is invalid. (Exception from HRESULT: 0x8007000D) “</p>
</blockquote>
<p><strong>Solution:</strong></p>
<p>The issue has to do with creating Users and User Groups without the ‘SAMACCOUNTNAME’ field while coding with Powershell. Windows Server 2008 R2 generates a unique Pre-2000 username starting with ‘$’ and a series of numbers following. When using the ‘-migrationtable’ trigger, it causes import-gpo cmdlet to validate the “destination users” PRIOR to importing the group policy. If it cannot resolve the User or User group, it will cause the ‘’HRESULT error’.</p>
<p>The following lines were added to the Powershell Script for creating a User Group, which corrected this issue:</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#039;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># Where $objworker was the AD method and $ADobjname was the name of the user / group</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> $objworker.put(<span style="color:#006080;">&quot;sAMAccountName&quot;</span>, <span style="color:#006080;">&quot;$ADobjname&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#039;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span> $objworker.SetInfo()</pre>
<p><!--CRLF--></div>
</div>
<p>&#160;</p>
<p>Depending on your network, the <strong>fix </strong>can be done in two ways:</p>
<ol>
<li>Ensure the “Pre-Windows 2000 name” is the same as the “Standard Windows Name” </li>
<li>Correct the Migration Table to Use the Pre-Windows 2000 Names for the ‘Destination’ </li>
</ol>
<p><strong>Simple fix </strong>– just wish that the error would be more like “Errors in Migration Table”. The error message of “The Data Is Invalid “ is useless in my opinion. </p>
<p>Happy Coding!</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/471/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/471/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/471/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=471&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2010/04/20/powershell-import-gpo-the-data-is-invalid-fixed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerShell Script: Encrypting / Decrypting A String &#8211; Function Encrypt-String</title>
		<link>http://bittangents.com/2010/03/20/powershell-script-encrypting-decrypting-a-string-function-encrypt-string/</link>
		<comments>http://bittangents.com/2010/03/20/powershell-script-encrypting-decrypting-a-string-function-encrypt-string/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 15:40:26 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Powershell Tangents]]></category>

		<guid isPermaLink="false">http://brentblawat.wordpress.com/2010/03/20/powershell-script-encrypting-decrypting-a-string-function-encrypt-string/</guid>
		<description><![CDATA[By: Brenton Blawat The encryption and decryption of strings is essential when creating an enterprise product that has clear text passwords. This function displays how to encrypt and decrypt a string using Powershell using Richard’s code located at http://poshcode.org/116. While I found his code very useful, he didn’t explain the syntax and is why I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=468&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>By: Brenton Blawat</strong></p>
<p>The encryption and decryption of strings is essential when creating an enterprise product that has clear text passwords. This function displays how to encrypt and decrypt a string using Powershell using Richard’s code located at <a title="http://poshcode.org/116" href="http://poshcode.org/116">http://poshcode.org/116</a>. While I found his code very useful, he didn’t explain the syntax and is why I am reposting this with the proper information. </p>
<p>I also decided to make this into an endless loop for an administrator to use to encrypt multiple passwords in a row. I found this to be useful as I never had to encrypt just one password. </p>
<h2></h2>
<h2>Important for your security!!</h2>
<p>In order to ensure your application is safe from an attacker be certain to perform each of the following:</p>
<p>1.&#160; Change the $salt variable and $init variables. These variables should be at least 8 characters long but should be changed or your application is subject to a brute force attack if someone determines you are using my code!</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#0000ff;">function</span> Encrypt-String($String, $Passphrase, $salt=<span style="color:#006080;">&quot;SaltCrypto&quot;</span>, $init=<span style="color:#006080;">&quot;IV_Password&quot;</span>, [<span style="color:#0000ff;">switch</span>]$arrayOutput)</pre>
<p><!--CRLF--></div>
</div>
<p>2.&#160; Change the Passphrase that is passed into the function. I suggest a 12-18 character Passphrase to prevent the above brute force attack.</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> $encrypted = Encrypt-String $string <span style="color:#006080;">&quot;MyStrongPassword&quot;</span></pre>
<p><!--CRLF--></div>
</div>
<p>3.&#160; Be sure to pass the right Passphrase into the function for decryption. If you pass the wrong key into the function, you will not get the correct password returned from the function.</p>
<h2>Function for Encrypting / Decrypting A String in PowerShell</h2>
<p><strong><a href="http://www.brentblawat.com/blog/codesnippets/EncryptDecryptString.PS1" target="_blank">Download PS1 Here</a></strong></p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;height:1839px;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;">#################</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> <span style="color:#008000;"># Powershell Allows The Loading of .NET Assemblies</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span> <span style="color:#008000;"># Load the Security assembly to use with this script </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span> <span style="color:#008000;">#################</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span> [Reflection.Assembly]::LoadWithPartialName(<span style="color:#006080;">&quot;System.Security&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span> <span style="color:#008000;">#################</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span> <span style="color:#008000;"># This function is to Encrypt A String.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span> <span style="color:#008000;"># $string is the string to encrypt, $passphrase is a second security &quot;password&quot; that has to be passed to decrypt.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span> <span style="color:#008000;"># $salt is used during the generation of the crypto password to prevent password guessing.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span> <span style="color:#008000;"># $init is used to compute the crypto hash -- a checksum of the encryption</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span> <span style="color:#008000;">#################</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span> <span style="color:#0000ff;">function</span> Encrypt-String($String, $Passphrase, $salt=<span style="color:#006080;">&quot;SaltCrypto&quot;</span>, $init=<span style="color:#006080;">&quot;IV_Password&quot;</span>, [<span style="color:#0000ff;">switch</span>]$arrayOutput)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span> {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span>     <span style="color:#008000;"># Create a COM Object for RijndaelManaged Cryptography</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum16">  16:</span>     $r = new-Object System.Security.Cryptography.RijndaelManaged</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum17">  17:</span>     <span style="color:#008000;"># Convert the Passphrase to UTF8 Bytes</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum18">  18:</span>     $pass = [Text.Encoding]::UTF8.GetBytes($Passphrase)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum19">  19:</span>     <span style="color:#008000;"># Convert the Salt to UTF Bytes</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum20">  20:</span>     $salt = [Text.Encoding]::UTF8.GetBytes($salt)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum21">  21:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum22">  22:</span>     <span style="color:#008000;"># Create the Encryption Key using the passphrase, salt and SHA1 algorithm at 256 bits</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum23">  23:</span>     $r.Key = (new-Object Security.Cryptography.PasswordDeriveBytes $pass, $salt, <span style="color:#006080;">&quot;SHA1&quot;</span>, 5).GetBytes(32) <span style="color:#008000;">#256/8</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum24">  24:</span>     <span style="color:#008000;"># Create the Intersecting Vector Cryptology Hash with the init</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum25">  25:</span>     $r.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash( [Text.Encoding]::UTF8.GetBytes($init) )[0..15]</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum26">  26:</span>     </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum27">  27:</span>     <span style="color:#008000;"># Starts the New Encryption using the Key and IV   </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum28">  28:</span>     $c = $r.CreateEncryptor()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum29">  29:</span>     <span style="color:#008000;"># Creates a MemoryStream to do the encryption in</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum30">  30:</span>     $ms = new-Object IO.MemoryStream</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum31">  31:</span>     <span style="color:#008000;"># Creates the new Cryptology Stream --&gt; Outputs to $MS or Memory Stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum32">  32:</span>     $cs = new-Object Security.Cryptography.CryptoStream $ms,$c,<span style="color:#006080;">&quot;Write&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum33">  33:</span>     <span style="color:#008000;"># Starts the new Cryptology Stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum34">  34:</span>     $sw = new-Object IO.StreamWriter $cs</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum35">  35:</span>     <span style="color:#008000;"># Writes the string in the Cryptology Stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum36">  36:</span>     $sw.Write($String)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum37">  37:</span>     <span style="color:#008000;"># Stops the stream writer</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum38">  38:</span>     $sw.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum39">  39:</span>     <span style="color:#008000;"># Stops the Cryptology Stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum40">  40:</span>     $cs.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum41">  41:</span>     <span style="color:#008000;"># Stops writing to Memory</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum42">  42:</span>     $ms.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum43">  43:</span>     <span style="color:#008000;"># Clears the IV and HASH from memory to prevent memory read attacks</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum44">  44:</span>     $r.Clear()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum45">  45:</span>     <span style="color:#008000;"># Takes the MemoryStream and puts it to an array</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum46">  46:</span>     [byte[]]$result = $ms.ToArray()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum47">  47:</span>     <span style="color:#008000;"># Converts the array from Base 64 to a string and returns</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum48">  48:</span>     <span style="color:#0000ff;">return</span> [Convert]::ToBase64String($result)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum49">  49:</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum50">  50:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum51">  51:</span> <span style="color:#0000ff;">function</span> Decrypt-String($Encrypted, $Passphrase, $salt=<span style="color:#006080;">&quot;SaltCrypto&quot;</span>, $init=<span style="color:#006080;">&quot;IV_Password&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum52">  52:</span> {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum53">  53:</span>     <span style="color:#008000;"># If the value in the Encrypted is a string, convert it to Base64</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum54">  54:</span>     <span style="color:#0000ff;">if</span>($Encrypted <span style="color:#cc6633;">-is</span> [string]){</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum55">  55:</span>         $Encrypted = [Convert]::FromBase64String($Encrypted)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum56">  56:</span>        }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum57">  57:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum58">  58:</span>     <span style="color:#008000;"># Create a COM Object for RijndaelManaged Cryptography</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum59">  59:</span>     $r = new-Object System.Security.Cryptography.RijndaelManaged</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum60">  60:</span>     <span style="color:#008000;"># Convert the Passphrase to UTF8 Bytes</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum61">  61:</span>     $pass = [Text.Encoding]::UTF8.GetBytes($Passphrase)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum62">  62:</span>     <span style="color:#008000;"># Convert the Salt to UTF Bytes</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum63">  63:</span>     $salt = [Text.Encoding]::UTF8.GetBytes($salt)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum64">  64:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum65">  65:</span>     <span style="color:#008000;"># Create the Encryption Key using the passphrase, salt and SHA1 algorithm at 256 bits</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum66">  66:</span>     $r.Key = (new-Object Security.Cryptography.PasswordDeriveBytes $pass, $salt, <span style="color:#006080;">&quot;SHA1&quot;</span>, 5).GetBytes(32) <span style="color:#008000;">#256/8</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum67">  67:</span>     <span style="color:#008000;"># Create the Intersecting Vector Cryptology Hash with the init</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum68">  68:</span>     $r.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash( [Text.Encoding]::UTF8.GetBytes($init) )[0..15]</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum69">  69:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum70">  70:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum71">  71:</span>     <span style="color:#008000;"># Create a new Decryptor</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum72">  72:</span>     $d = $r.CreateDecryptor()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum73">  73:</span>     <span style="color:#008000;"># Create a New memory stream with the encrypted value.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum74">  74:</span>     $ms = new-Object IO.MemoryStream @(,$Encrypted)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum75">  75:</span>     <span style="color:#008000;"># Read the new memory stream and read it in the cryptology stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum76">  76:</span>     $cs = new-Object Security.Cryptography.CryptoStream $ms,$d,<span style="color:#006080;">&quot;Read&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum77">  77:</span>     <span style="color:#008000;"># Read the new decrypted stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum78">  78:</span>     $sr = new-Object IO.StreamReader $cs</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum79">  79:</span>     <span style="color:#008000;"># Return from the function the stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum80">  80:</span>     Write-Output $sr.ReadToEnd()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum81">  81:</span>     <span style="color:#008000;"># Stops the stream    </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum82">  82:</span>     $sr.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum83">  83:</span>     <span style="color:#008000;"># Stops the crypology stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum84">  84:</span>     $cs.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum85">  85:</span>     <span style="color:#008000;"># Stops the memory stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum86">  86:</span>     $ms.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum87">  87:</span>     <span style="color:#008000;"># Clears the RijndaelManaged Cryptology IV and Key</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum88">  88:</span>     $r.Clear()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum89">  89:</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum90">  90:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum91">  91:</span> <span style="color:#008000;"># This clears the screen of the output from the loading of the assembly.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum92">  92:</span> cls</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum93">  93:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum94">  94:</span> <span style="color:#008000;"># $me will never = 1, so It will run indefinately</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum95">  95:</span> $me = 0</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum96">  96:</span>     write-host <span style="color:#006080;">&quot;To End This Application, Close the Window&quot;</span>    </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum97">  97:</span>     Write-host <span style="color:#006080;">&quot;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum98">  98:</span> do</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum99">  99:</span> {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum100"> 100:</span>     <span style="color:#008000;"># Prompt the user for the password    </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum101"> 101:</span>     $string = read-host <span style="color:#006080;">&quot;Please Enter User Password&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum102"> 102:</span>     <span style="color:#008000;"># Encrypt the string and store it into the $encrypted variable</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum103"> 103:</span>     $encrypted = Encrypt-String $string <span style="color:#006080;">&quot;MyStrongPassword&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum104"> 104:</span>     <span style="color:#008000;"># Write result to the screen</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum105"> 105:</span>     write-host <span style="color:#006080;">&quot;Encrypted Password is: $encrypted&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum106"> 106:</span>     write-host <span style="color:#006080;">&quot;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum107"> 107:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum108"> 108:</span>     write-host <span style="color:#006080;">&quot;Testing Decryption of Password...&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum109"> 109:</span>     </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum110"> 110:</span>     <span style="color:#008000;"># Decrypts the string and stores the decrypted value in $decrypted</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum111"> 111:</span>     $decrypted = Decrypt-String $encrypted <span style="color:#006080;">&quot;MyStrongPassword&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum112"> 112:</span>     <span style="color:#008000;"># Writes the decrpted value to the screen</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum113"> 113:</span>     write-host <span style="color:#006080;">&quot;Decrypted Password is: $decrypted&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum114"> 114:</span>     write-host <span style="color:#006080;">&quot;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum115"> 115:</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum116"> 116:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum117"> 117:</span> <span style="color:#0000ff;">while</span> ($me <span style="color:#cc6633;">-ne</span> 1)</pre>
<p><!--CRLF--></div>
</div>
<p><strong>To use this Function: </strong></p>
<p><strong>Start</strong> &gt; <strong>Run </strong>&gt; Type <strong>powershell.exe –noexit c:\location\EncryptDecryptString.ps1</strong> </p>
<p><strong>** When you are done close the window.</strong></p>
<h2>Function for Encrypting Username and Passwords in PowerShell</h2>
<p><strong><a href="http://www.brentblawat.com/blog/codesnippets/EncryptDecryptStringUP.PS1" target="_blank">Download PS1 Here</a></strong></p>
<p>You will notice that I changed the Passphrase for both the username and the password. This is not necessary, however, it adds another layer of security. Try not to encrypt everything with the same passphrase. If one item gets compromised, everything encrypted under that passphrase is compromised.</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;height:2019px;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;">#################</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> <span style="color:#008000;"># Powershell Allows The Loading of .NET Assemblies</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span> <span style="color:#008000;"># Load the Security assembly to use with this script </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span> <span style="color:#008000;">#################</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span> [Reflection.Assembly]::LoadWithPartialName(<span style="color:#006080;">&quot;System.Security&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span> <span style="color:#008000;">#################</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span> <span style="color:#008000;"># This function is to Encrypt A String.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span> <span style="color:#008000;"># $string is the string to encrypt, $passphrase is a second security &quot;password&quot; that has to be passed to decrypt.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span> <span style="color:#008000;"># $salt is used during the generation of the crypto password to prevent password guessing.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span> <span style="color:#008000;"># $init is used to compute the crypto hash -- a checksum of the encryption</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span> <span style="color:#008000;">#################</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span> <span style="color:#0000ff;">function</span> Encrypt-String($String, $Passphrase, $salt=<span style="color:#006080;">&quot;SaltCrypto&quot;</span>, $init=<span style="color:#006080;">&quot;IV_Password&quot;</span>, [<span style="color:#0000ff;">switch</span>]$arrayOutput)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span> {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span>     <span style="color:#008000;"># Create a COM Object for RijndaelManaged Cryptography</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum16">  16:</span>     $r = new-Object System.Security.Cryptography.RijndaelManaged</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum17">  17:</span>     <span style="color:#008000;"># Convert the Passphrase to UTF8 Bytes</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum18">  18:</span>     $pass = [Text.Encoding]::UTF8.GetBytes($Passphrase)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum19">  19:</span>     <span style="color:#008000;"># Convert the Salt to UTF Bytes</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum20">  20:</span>     $salt = [Text.Encoding]::UTF8.GetBytes($salt)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum21">  21:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum22">  22:</span>     <span style="color:#008000;"># Create the Encryption Key using the passphrase, salt and SHA1 algorithm at 256 bits</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum23">  23:</span>     $r.Key = (new-Object Security.Cryptography.PasswordDeriveBytes $pass, $salt, <span style="color:#006080;">&quot;SHA1&quot;</span>, 5).GetBytes(32) <span style="color:#008000;">#256/8</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum24">  24:</span>     <span style="color:#008000;"># Create the Intersecting Vector Cryptology Hash with the init</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum25">  25:</span>     $r.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash( [Text.Encoding]::UTF8.GetBytes($init) )[0..15]</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum26">  26:</span>     </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum27">  27:</span>     <span style="color:#008000;"># Starts the New Encryption using the Key and IV   </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum28">  28:</span>     $c = $r.CreateEncryptor()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum29">  29:</span>     <span style="color:#008000;"># Creates a MemoryStream to do the encryption in</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum30">  30:</span>     $ms = new-Object IO.MemoryStream</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum31">  31:</span>     <span style="color:#008000;"># Creates the new Cryptology Stream --&gt; Outputs to $MS or Memory Stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum32">  32:</span>     $cs = new-Object Security.Cryptography.CryptoStream $ms,$c,<span style="color:#006080;">&quot;Write&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum33">  33:</span>     <span style="color:#008000;"># Starts the new Cryptology Stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum34">  34:</span>     $sw = new-Object IO.StreamWriter $cs</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum35">  35:</span>     <span style="color:#008000;"># Writes the string in the Cryptology Stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum36">  36:</span>     $sw.Write($String)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum37">  37:</span>     <span style="color:#008000;"># Stops the stream writer</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum38">  38:</span>     $sw.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum39">  39:</span>     <span style="color:#008000;"># Stops the Cryptology Stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum40">  40:</span>     $cs.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum41">  41:</span>     <span style="color:#008000;"># Stops writing to Memory</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum42">  42:</span>     $ms.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum43">  43:</span>     <span style="color:#008000;"># Clears the IV and HASH from memory to prevent memory read attacks</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum44">  44:</span>     $r.Clear()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum45">  45:</span>     <span style="color:#008000;"># Takes the MemoryStream and puts it to an array</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum46">  46:</span>     [byte[]]$result = $ms.ToArray()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum47">  47:</span>     <span style="color:#008000;"># Converts the array from Base 64 to a string and returns</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum48">  48:</span>     <span style="color:#0000ff;">return</span> [Convert]::ToBase64String($result)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum49">  49:</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum50">  50:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum51">  51:</span> <span style="color:#0000ff;">function</span> Decrypt-String($Encrypted, $Passphrase, $salt=<span style="color:#006080;">&quot;SaltCrypto&quot;</span>, $init=<span style="color:#006080;">&quot;IV_Password&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum52">  52:</span> {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum53">  53:</span>     <span style="color:#008000;"># If the value in the Encrypted is a string, convert it to Base64</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum54">  54:</span>     <span style="color:#0000ff;">if</span>($Encrypted <span style="color:#cc6633;">-is</span> [string]){</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum55">  55:</span>         $Encrypted = [Convert]::FromBase64String($Encrypted)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum56">  56:</span>        }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum57">  57:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum58">  58:</span>     <span style="color:#008000;"># Create a COM Object for RijndaelManaged Cryptography</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum59">  59:</span>     $r = new-Object System.Security.Cryptography.RijndaelManaged</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum60">  60:</span>     <span style="color:#008000;"># Convert the Passphrase to UTF8 Bytes</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum61">  61:</span>     $pass = [Text.Encoding]::UTF8.GetBytes($Passphrase)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum62">  62:</span>     <span style="color:#008000;"># Convert the Salt to UTF Bytes</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum63">  63:</span>     $salt = [Text.Encoding]::UTF8.GetBytes($salt)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum64">  64:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum65">  65:</span>     <span style="color:#008000;"># Create the Encryption Key using the passphrase, salt and SHA1 algorithm at 256 bits</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum66">  66:</span>     $r.Key = (new-Object Security.Cryptography.PasswordDeriveBytes $pass, $salt, <span style="color:#006080;">&quot;SHA1&quot;</span>, 5).GetBytes(32) <span style="color:#008000;">#256/8</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum67">  67:</span>     <span style="color:#008000;"># Create the Intersecting Vector Cryptology Hash with the init</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum68">  68:</span>     $r.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash( [Text.Encoding]::UTF8.GetBytes($init) )[0..15]</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum69">  69:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum70">  70:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum71">  71:</span>     <span style="color:#008000;"># Create a new Decryptor</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum72">  72:</span>     $d = $r.CreateDecryptor()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum73">  73:</span>     <span style="color:#008000;"># Create a New memory stream with the encrypted value.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum74">  74:</span>     $ms = new-Object IO.MemoryStream @(,$Encrypted)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum75">  75:</span>     <span style="color:#008000;"># Read the new memory stream and read it in the cryptology stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum76">  76:</span>     $cs = new-Object Security.Cryptography.CryptoStream $ms,$d,<span style="color:#006080;">&quot;Read&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum77">  77:</span>     <span style="color:#008000;"># Read the new decrypted stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum78">  78:</span>     $sr = new-Object IO.StreamReader $cs</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum79">  79:</span>     <span style="color:#008000;"># Return from the function the stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum80">  80:</span>     Write-Output $sr.ReadToEnd()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum81">  81:</span>     <span style="color:#008000;"># Stops the stream    </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum82">  82:</span>     $sr.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum83">  83:</span>     <span style="color:#008000;"># Stops the crypology stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum84">  84:</span>     $cs.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum85">  85:</span>     <span style="color:#008000;"># Stops the memory stream</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum86">  86:</span>     $ms.Close()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum87">  87:</span>     <span style="color:#008000;"># Clears the RijndaelManaged Cryptology IV and Key</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum88">  88:</span>     $r.Clear()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum89">  89:</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum90">  90:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum91">  91:</span> <span style="color:#008000;"># This clears the screen of the output from the loading of the assembly.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum92">  92:</span> cls</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum93">  93:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum94">  94:</span> <span style="color:#008000;"># $me will never = 1, so It will run indefinately</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum95">  95:</span> $me = 0</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum96">  96:</span>     write-host <span style="color:#006080;">&quot;To End This Application, Close the Window&quot;</span>    </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum97">  97:</span>     Write-host <span style="color:#006080;">&quot;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum98">  98:</span> do</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum99">  99:</span> {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum100"> 100:</span>     <span style="color:#008000;"># Prompt the user for the password    </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum101"> 101:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum102"> 102:</span>     $ustring = read-host <span style="color:#006080;">&quot;(Case Sensitive) Please Enter Username&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum103"> 103:</span>     $pstring = read-host <span style="color:#006080;">&quot;(Case Sensitive) Please Enter User Password&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum104"> 104:</span>     <span style="color:#008000;"># Encrypt the string and store it into the $encrypted variable</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum105"> 105:</span>     $uencrypted = Encrypt-String $ustring <span style="color:#006080;">&quot;U_MyStrongPassword&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum106"> 106:</span>     $pencrypted = Encrypt-String $pstring <span style="color:#006080;">&quot;P_MyStrongPassword&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum107"> 107:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum108"> 108:</span>     <span style="color:#008000;"># Write result to the screen</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum109"> 109:</span>     write-host <span style="color:#006080;">&quot;Encrypted Username is: $uencrypted&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum110"> 110:</span>     write-host <span style="color:#006080;">&quot;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum111"> 111:</span>     write-host <span style="color:#006080;">&quot;Encrypted Password is: $pencrypted&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum112"> 112:</span>     write-host <span style="color:#006080;">&quot;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum113"> 113:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum114"> 114:</span>     write-host <span style="color:#006080;">&quot;Testing Decryption of Username / Password...&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum115"> 115:</span>     write-host <span style="color:#006080;">&quot;&quot;</span>    </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum116"> 116:</span>     <span style="color:#008000;"># Decrypts the string and stores the decrypted value in $decrypted</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum117"> 117:</span>     $udecrypted = Decrypt-String $uencrypted <span style="color:#006080;">&quot;U_MyStrongPassword&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum118"> 118:</span>     $pdecrypted = Decrypt-String $pencrypted <span style="color:#006080;">&quot;P_MyStrongPassword&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum119"> 119:</span>     </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum120"> 120:</span>     <span style="color:#008000;"># Writes the decrpted value to the screen</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum121"> 121:</span>     write-host <span style="color:#006080;">&quot;Decrypted Password is: $udecrypted&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum122"> 122:</span>     write-host <span style="color:#006080;">&quot;&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum123"> 123:</span>     write-host <span style="color:#006080;">&quot;Decrypted Password is: $pdecrypted&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum124"> 124:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum125"> 125:</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum126"> 126:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum127"> 127:</span> <span style="color:#0000ff;">while</span> ($me <span style="color:#cc6633;">-ne</span> 1)</pre>
<p><!--CRLF--></div>
</div>
<p><strong>To use this Function: </strong></p>
<p><strong>Start</strong> &gt; <strong>Run </strong>&gt; Type <strong>powershell.exe –noexit c:\location\EncryptDecryptStringUP.ps1</strong> </p>
<p><strong>** When you are done close the window.</strong></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/468/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/468/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/468/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/468/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/468/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/468/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/468/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/468/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/468/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/468/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/468/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/468/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/468/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/468/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=468&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2010/03/20/powershell-script-encrypting-decrypting-a-string-function-encrypt-string/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerShell Script: Finding A Distinguished Name of a Group/User: Function Find-DN</title>
		<link>http://bittangents.com/2010/03/08/powershell-script-finding-a-distinguished-name-of-a-groupuser-function-find-dn/</link>
		<comments>http://bittangents.com/2010/03/08/powershell-script-finding-a-distinguished-name-of-a-groupuser-function-find-dn/#comments</comments>
		<pubDate>Mon, 08 Mar 2010 22:18:43 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Powershell Tangents]]></category>

		<guid isPermaLink="false">http://brentblawat.wordpress.com/2010/03/08/powershell-script-finding-a-distinguished-name-of-a-groupuser-function-find-dn/</guid>
		<description><![CDATA[By: Brenton Blawat This article explains the the method by which one would be able to Search Active Directory for the distinguished name of a User or Group. This is helpful when trying to add an object to Active Directory or adding Users to Groups. Function Find-DN Finding Distinguished Name: Download PS1 Here 1: # [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=465&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>By: Brenton Blawat</strong></p>
<p>This article explains the the method by which one would be able to Search Active Directory for the distinguished name of a User or Group. This is helpful when trying to add an object to Active Directory or adding Users to Groups.</p>
<p><strong>Function Find-DN Finding Distinguished Name:</strong> <a href="http://www.brentblawat.com/blog/codesnippets/find-dn.ps1"><strong>Download PS1 Here</strong></a></p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># Function Find Distinguished Name</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> <span style="color:#0000ff;">function</span> find-dn { <span style="color:#0000ff;">param</span>([string]$adfindtype, [string]$cName)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>     <span style="color:#008000;"># Create A New ADSI Call</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span>     $root = [ADSI]<span style="color:#006080;">''</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span>     <span style="color:#008000;"># Create a New DirectorySearcher Object</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>     $searcher = new-object System.DirectoryServices.DirectorySearcher($root)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span>     <span style="color:#008000;"># Set the filter to search for a specific CNAME</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span>     $searcher.<span style="color:#0000ff;">filter</span> = <span style="color:#006080;">&quot;(&amp;(objectClass=$adfindtype) (CN=$cName))&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span>     <span style="color:#008000;"># Set results in $adfind variable</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span>     $adfind = $searcher.findall()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span>     </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span>     <span style="color:#008000;"># If Search has Multiple Answers </span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span>     <span style="color:#0000ff;">if</span> ($adfind.count <span style="color:#cc6633;">-gt</span> 1) {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span>         $count = 0 </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span>         <span style="color:#0000ff;">foreach</span>($i <span style="color:#0000ff;">in</span> $adfind)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum16">  16:</span>         {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum17">  17:</span>             <span style="color:#008000;"># Write Answers On Screen</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum18">  18:</span>             write-host $count <span style="color:#006080;">&quot;: &quot;</span> $i.path</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum19">  19:</span>             $count += 1</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum20">  20:</span>         }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum21">  21:</span>         <span style="color:#008000;"># Prompt User For Selection</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum22">  22:</span>         $selection = Read-Host <span style="color:#006080;">&quot;Please select item: &quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum23">  23:</span>         <span style="color:#008000;"># Return the Selection</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum24">  24:</span>         <span style="color:#0000ff;">return</span> $adfind[$selection].path</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum25">  25:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum26">  26:</span>     <span style="color:#008000;"># Return The Answer</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum27">  27:</span>     <span style="color:#0000ff;">return</span> $adfind[0].path</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum28">  28:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p><strong>Using this Function:</strong></p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># To use the function to find a User:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> find-dn <span style="color:#006080;">&quot;user&quot;</span> <span style="color:#006080;">&quot;Blawat&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span> <span style="color:#008000;"># To use the function to find a Group:</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span> find-dn <span style="color:#006080;">&quot;group&quot;</span> <span style="color:#006080;">&quot;IT Help Desk&quot;</span></pre>
<p><!--CRLF--></div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/465/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/465/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/465/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=465&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2010/03/08/powershell-script-finding-a-distinguished-name-of-a-groupuser-function-find-dn/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>
	</item>
		<item>
		<title>2010 Volkswagen CC Review &#8211; A test Drive Bashing</title>
		<link>http://bittangents.com/2010/02/23/2010-volkswagen-cc-review-a-test-drive-bashing/</link>
		<comments>http://bittangents.com/2010/02/23/2010-volkswagen-cc-review-a-test-drive-bashing/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:53:48 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Car Tangents]]></category>

		<guid isPermaLink="false">http://brentblawat.wordpress.com/2010/02/23/2010-volkswagen-cc-review-a-test-drive-bashing/</guid>
		<description><![CDATA[By: Brenton Blawat Originally Posted &#8211; February 23, 2010 UPDATED 9/21/2010 - OK… I was a bit harsh on my review, and honestly I was my first bitter impression of the vehicle when it was first released. I’ve had comments of “did you really drive this vehicle” and “worst car reviews that I have ever [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=456&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>By: Brenton Blawat</strong></p>
<p><em>Originally Posted &#8211; February 23, 2010</em></p>
<p><strong></strong></p>
<p><strong>UPDATED 9/21/2010 </strong>- OK… I was a bit harsh on my review, and honestly I was my first bitter impression of the vehicle when it was first released. I’ve had comments of “<em>did you really drive this vehicle</em>” and “<em>worst car reviews that I have ever seen”</em>. Well for starters, I did really drive 2 CC’s at <a href="http://www.foxvalleyvw.com/" target="_blank">Fox Valley Volkswagen, in Schaumburg, IL</a> and another one at <a href="http://www.hallcars.com/" target="_blank">Hall Mazda and Volkswagen, in Brookfield, WI.</a> Both dealerships are wonderful dealerships with very knowledgeable staff. My grip is directly with the Volkswagen CC. I’ve updated the entire article to display WHY I bashed the 2010 Volkswagen CC. So here we go again <img src='http://s0.wp.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;</p>
<p>This article is the first of many car reviews for 2009/2010 vehicles. I chose the Volkswagen CC as the first review as it was the most intriguing to write about out of the 20 or so vehicles I was able to test drive.</p>
<p><a href="http://brentblawat.files.wordpress.com/2010/02/cc09scr_3qtr_performance_800x600.jpg"><img style="display:inline;border-width:0;" title="cc09scr_3qtr_performance_800x600" border="0" alt="cc09scr_3qtr_performance_800x600" src="http://brentblawat.files.wordpress.com/2010/02/cc09scr_3qtr_performance_800x600_thumb.jpg?w=370&#038;h=278" width="370" height="278" /></a> </p>
<p><strong>2010 Volkswagen CC</strong>&#160;</p>
<p>In an effort to raise the ‘class’ bar for VW, the Volkswagen created the Passat CC to replace standard VW Passat. At a first glance, you see a <a href="http://www.mercedes-amg.com/?lang=usa#/cls63-overview">Mercedes CLS-class</a> but after closer inspection, you realize the branding on the front is Volkswagen. This immediately intrigued me, and a test drive was in the works for the vehicle. After the test drive(s), I thought, with such sleek exterior styling, how did Volkswagen get it <u>SO</u> wrong?!!</p>
<p>&#160;</p>
<p><strong></strong></p>
<p><strong>Interior – Is it really that Luxurious?</strong></p>
<p><a href="http://brentblawat.files.wordpress.com/2010/02/cc10scr_steeringwheel_800x600.jpg"><img style="display:inline;border-width:0;" title="cc10scr_steeringwheel_800x600" border="0" alt="cc10scr_steeringwheel_800x600" src="http://brentblawat.files.wordpress.com/2010/02/cc10scr_steeringwheel_800x600_thumb.jpg?w=384&#038;h=289" width="384" height="289" /></a> <a href="http://brentblawat.files.wordpress.com/2010/02/pas10scr_steeringwheel_i01_800x600.jpg"><img style="display:inline;border-width:0;" title="pas10scr_steeringWheel_i01_800x600" border="0" alt="pas10scr_steeringWheel_i01_800x600" src="http://brentblawat.files.wordpress.com/2010/02/pas10scr_steeringwheel_i01_800x600_thumb.jpg?w=386&#038;h=290" width="386" height="290" /></a> </p>
<p><strong>Can anyone tell me which vehicle is the CC and which is the Passat?</strong></p>
<p>With interior reminiscent of its Passat sister, I was really hoping for more. The dashboard gauges and steering wheels are exactly the same, while the shifter and the seats are slightly different. To answer my question above, the image on the [left] is the Passat CC and the Image on the [right] is the Standard Passat. Scary how close the interiors are. If the CC is supposed to be a ‘luxury sedan’, above it’s sister Passat, can’t they do something different other than the fake wood trim? – That’s about all they changed.</p>
<p>Why is this such a big deal? The Washington Times raved the Passat CC as having “classy-looking interior”. The new slogan speaks of luxury – but is it really? The Touch Screen radio is more of a gadget than a luxury option like the i-Drive on the BMW. The stereo is good but is known for cutting off at the top end when you are blasting the stereo – not so cool. I also do not like the fact that navigation is such a costly upgrade ($2,640) for such a small component to add to the stereo.</p>
<p>The ride is what I would expect from a German car with low road noise and it passes the door closing test. <em>The door closing test is one where when you shut your door it is a solid thud. It shouldn’t have any radiating vibrations or rattles coming from inside the door or in the cabin.</em> While the frame and chassis of the vehicle are solid, the interior still needs some major work to make you feel like you are in a luxury car.</p>
<p>I still don’t like the cylindrical shifter. It really forces me to stay away from playing in manual sport mode. When I am driving a ‘luxury sedan’ that has 280hp, I’d like to be able to feel like I can play. I just feel like the sliding the shifter to and from the manual sport mode just doesn’t have the same effect; much like having a shifter on the tree.</p>
<p>While I can admit that the CC’s seats are comfortable, I get very close to the same support in the Passat. The rear seat has a cup holder as part of the seat making the vehicle a true four seat vehicle. There will be no cramming three kids in the back and any person with young children that requires a child seat, be disappointed with cleaning the grooves in the cup holder and its cover. What about putting a child seat in the center like most parents do to keep their children in rear view? Yet another <em>WHAT?!? </em>Volkswagen moment. My second concern with this center console is hauling any items in the back seat such as a large cooler (one which wouldn’t fit in the opening of the trunk). I would be afraid of cracking the plastic on the cover of this cup holder. Good thing there are talks by Volkswagen to have a five seat option; but why not on the first release?!</p>
<p>The second gripe I have with the Volkswagen CC has to do with the headroom – more appropriately the panoramic sunroof. Such a fancy name for a vent and obviously a mistake to not design it to retract. It comes off as an after thought of “Do you think people would like this feature? Crap!”. The sunroof doesn’t retract it only pops open to provide added cabin sunlight and ventilation. If you get a VW without the sunroof, your headroom is decreased by several inches and any six foot man would start to get a claustrophobic feeling inside the cabin. Also to mention, during the test drive, I was fortunate to have a friend with me, and she confirmed (with her being 5’9”) she felt as if the roof was collapsing on her as well. This is because we transitioned from a Passat to the CC which has one inch less head clearance. It seems anyone over 5’8” requires the panoramic sunroof which was only available on the luxury package &#8211; (at the time of posting) &#8211; another “really??” moment. Thank god they now offer this panoramic sun roof for the standard model. Talk about being out of touch with your market.</p>
<p><strong>Engine Performance</strong></p>
<p>Performance? Nothing new… nothing real exciting. They still have the same 2.0T and VR6 engines.</p>
<p>The first gripe I have with the Volkswagen CC has to do with the 2.0 liter turbocharged automatic. The dual clutch system (DCS) (or <em>direct shift gearbox (DSG)</em>; same thing) in the vehicle gives the feeling that you are consistently missing the gear at take-off, and during mid-gear acceleration (like the Lancer Rally Sport). While the salesman insisted it was the turbo lag – any seasoned turbo driver (such as myself) &#8211; knows that it’s the gear not engaging smoothly in the vehicle. <em>To know the difference &#8212; turbo lag dips the RPM prior to an explosive take-off. The feeling you will get is that you are riding the clutch before it engages. The result is feeling like you are going to break the transmission when driving it. </em>The throttle response is thus affected, and takes the fun out of driving the vehicle. When switching to the VR6 version of the VW CC, you’re immediately engaged and the engine grunt makes you feel – this is cool. The numerous <a href="http://www.vwforum.com/forums/f14/common-vr6-problems-16379/">reported issues</a> with the VR6 engines require a second thought which purchasing the vehicle for engine longevity over 90k. JD Power and associates rated the VR6 engine the LOWEST in it’s class.</p>
<p><strong><em>Midsized Sedan Performance Comparison</em></strong></p>
<table border="1" cellspacing="0" cellpadding="2" width="771">
<tbody>
<tr>
<td valign="top" width="87">
<p align="center"><strong>2010</strong></p>
</td>
<td valign="top" width="88">
<p align="center"><strong>Passat CC VR6</strong></p>
</td>
<td valign="top" width="87">
<p align="center"><strong>Nissan Maxima</strong></p>
</td>
<td valign="top" width="86">
<p align="center"><strong>Toyota Camry</strong></p>
</td>
<td valign="top" width="86">
<p align="center"><strong>Subaru Legacy GT</strong></p>
</td>
<td valign="top" width="85">
<p align="center"><strong>Dodge Charger RT</strong></p>
</td>
<td valign="top" width="84">
<p align="center"><strong>Ford Taurus SE</strong></p>
</td>
<td valign="top" width="84">
<p align="center"><strong>Pontiac G8 GT</strong></p>
</td>
<td valign="top" width="82">
<p align="center"><strong>Honda Accord EX</strong></p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>Cost</strong></p>
</td>
<td valign="top" width="88">
<p align="center">28,600 – 40,420</p>
</td>
<td valign="top" width="87">
<p align="center">30,400 – 33,180</p>
</td>
<td valign="top" width="86">
<p align="center">22,500-29,700</p>
</td>
<td valign="top" width="86">
<p align="center"><strong><font color="#ff0000">20,995 – 29,995</font></strong></p>
</td>
<td valign="top" width="85">
<p align="center">25,080 – 39,195</p>
</td>
<td valign="top" width="84">
<p align="center">25,170-37,170</p>
</td>
<td valign="top" width="84">
<p align="center">28,250-37,610</p>
</td>
<td valign="top" width="82">
<p align="center">21,855 – 29,305</p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>Engine</strong></p>
</td>
<td valign="top" width="88">
<p align="center">3.6 V6</p>
</td>
<td valign="top" width="87">
<p align="center">3.5L V6</p>
</td>
<td valign="top" width="86">
<p align="center">3.5L V6</p>
</td>
<td valign="top" width="86">
<p align="center">2.5L H4</p>
</td>
<td valign="top" width="85">
<p align="center">5.7L V8</p>
</td>
<td valign="top" width="84">
<p align="center">3.5L V6</p>
</td>
<td valign="top" width="84">
<p align="center">6.0L V8</p>
</td>
<td valign="top" width="82">
<p align="center">3.5L V6</p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>HP</strong></p>
</td>
<td valign="top" width="88">
<p align="center">280</p>
</td>
<td valign="top" width="87">
<p align="center">290</p>
</td>
<td valign="top" width="86">
<p align="center">268</p>
</td>
<td valign="top" width="86">
<p align="center">265</p>
</td>
<td valign="top" width="85">
<p align="center"><font color="#ff0000"><strong>368</strong></font></p>
</td>
<td valign="top" width="84">
<p align="center">263</p>
</td>
<td valign="top" width="84">
<p align="center">355</p>
</td>
<td valign="top" width="82">
<p align="center">271</p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>TQ</strong></p>
</td>
<td valign="top" width="88">
<p align="center">266</p>
</td>
<td valign="top" width="87">
<p align="center">261</p>
</td>
<td valign="top" width="86">
<p align="center">248</p>
</td>
<td valign="top" width="86">
<p align="center">258</p>
</td>
<td valign="top" width="85">
<p align="center"><font color="#ff0000"><strong>395</strong></font></p>
</td>
<td valign="top" width="84">
<p align="center">249</p>
</td>
<td valign="top" width="84">
<p align="center">385</p>
</td>
<td valign="top" width="82">
<p align="center">254</p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>0-60</strong></p>
</td>
<td valign="top" width="88">
<p align="center">6.6</p>
</td>
<td valign="top" width="87">
<p align="center">6.5</p>
</td>
<td valign="top" width="86">
<p align="center">6.2</p>
</td>
<td valign="top" width="86">
<p align="center">5.6</p>
</td>
<td valign="top" width="85">
<p align="center">5.7</p>
</td>
<td valign="top" width="84">
<p align="center">7.6</p>
</td>
<td valign="top" width="84">
<p align="center"><font color="#ff0000"><strong>5.3</strong></font></p>
</td>
<td valign="top" width="82">
<p align="center">7.5 </p>
</td>
</tr>
</tbody>
</table>
<p>&#160;</p>
<p>Summary – If it’s a performance midsize sedan you’re looking for, the Passat CC doesn’t line up. In fact, the Pontiac G8 GT starts at $31,000 and has been compared to a reasonable <a href="http://www.motortrend.com/cars/2009/pontiac/g8/index.html" target="_blank">BMW 5 series at Motor Trend.</a> For starting $35,000, you can get into a 2010 Ford Taurus SHO which has 365hp/250tq at 1500 RPM to put you to 60mph in 5.5 seconds; or the Charger SRT8. I was being fair to leave these out of the above specs even though the VR6 is the fastest engine selection for the Volkswagens. So when you get yourself into an on ramp race to the top, be assured you can beat a Ford Taurus SE and a Honda Accord Ex.</p>
<p><strong><em>Midsized Luxury Sedan Performance Comparison</em></strong></p>
<table border="1" cellspacing="0" cellpadding="2" width="771">
<tbody>
<tr>
<td valign="top" width="87">
<p align="center"><strong>2010</strong></p>
</td>
<td valign="top" width="88">
<p align="center"><strong>Passat CC VR6</strong></p>
</td>
<td valign="top" width="87">
<p align="center"><strong>BMW 3 Series</strong></p>
</td>
<td valign="top" width="86">
<p align="center"><strong>Audi A4</strong></p>
</td>
<td valign="top" width="86">
<p align="center"><strong>Infinity G37</strong></p>
</td>
<td valign="top" width="85">
<p align="center"><strong>Acura TL</strong></p>
</td>
<td valign="top" width="84">
<p align="center"><strong>Mercedes C-Class</strong></p>
</td>
<td valign="top" width="84">
<p align="center"><strong>Lexus IS350</strong></p>
</td>
<td valign="top" width="82">
<p align="center"><strong>Lincoln MKS</strong></p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>Cost</strong></p>
</td>
<td valign="top" width="88">
<p align="center">39,600 – 40,420</p>
</td>
<td valign="top" width="87">
<p align="center">32,850 – 50,700</p>
</td>
<td valign="top" width="86">
<p align="center">37,200 – 44,100</p>
</td>
<td valign="top" width="86">
<p align="center">33,250-46,950</p>
</td>
<td valign="top" width="85">
<p align="center">35,105 – 42,385</p>
</td>
<td valign="top" width="84">
<p align="center">33,990 – 58,200</p>
</td>
<td valign="top" width="84">
<p align="center">37,595 – 44,890</p>
</td>
<td valign="top" width="82">
<p align="center">40,870 &#8211; $47,760</p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>Engine</strong></p>
</td>
<td valign="top" width="88">
<p align="center">3.6 V6</p>
</td>
<td valign="top" width="87">
<p align="center">3.0L V6</p>
</td>
<td valign="top" width="86">
<p align="center">3.2L V6</p>
</td>
<td valign="top" width="86">
<p align="center">3.7 L V6</p>
</td>
<td valign="top" width="85">
<p align="center">3.7L V6</p>
</td>
<td valign="top" width="84">
<p align="center">3.0L V6</p>
</td>
<td valign="top" width="84">
<p align="center">3.5L V6</p>
</td>
<td valign="top" width="82">
<p align="center">3.5L V6</p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>HP</strong></p>
</td>
<td valign="top" width="88">
<p align="center">280</p>
</td>
<td valign="top" width="87">
<p align="center">300</p>
</td>
<td valign="top" width="86">
<p align="center">265</p>
</td>
<td valign="top" width="86">
<p align="center">328</p>
</td>
<td valign="top" width="85">
<p align="center">305</p>
</td>
<td valign="top" width="84">
<p align="center">268</p>
</td>
<td valign="top" width="84">
<p align="center">306</p>
</td>
<td valign="top" width="82">
<p align="center">355</p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>TQ</strong></p>
</td>
<td valign="top" width="88">
<p align="center">266</p>
</td>
<td valign="top" width="87">
<p align="center">300</p>
</td>
<td valign="top" width="86">
<p align="center">243</p>
</td>
<td valign="top" width="86">
<p align="center">269</p>
</td>
<td valign="top" width="85">
<p align="center">273</p>
</td>
<td valign="top" width="84">
<p align="center">258</p>
</td>
<td valign="top" width="84">
<p align="center">277</p>
</td>
<td valign="top" width="82">
<p align="center">325</p>
</td>
</tr>
<tr>
<td valign="top" width="87">
<p align="center"><strong>0-60</strong></p>
</td>
<td valign="top" width="88">
<p align="center">6.6</p>
</td>
<td valign="top" width="87">
<p align="center">5.2</p>
</td>
<td valign="top" width="86">
<p align="center">6.9</p>
</td>
<td valign="top" width="86">
<p align="center">5.5</p>
</td>
<td valign="top" width="85">
<p align="center">5.5</p>
</td>
<td valign="top" width="84">
<p align="center">6.3</p>
</td>
<td valign="top" width="84">
<p align="center">5.5</p>
</td>
<td valign="top" width="82">
<p align="center">5.5</p>
</td>
</tr>
</tbody>
</table>
<p>Please note for this comparison I decided to increase the bottom line price of the CC to that of the VR6 Sport Package. </p>
<p>Summary – With all things considered, it doesn’t look like the Passat CC can keep up with these vehicles either from a performance standpoint. In this section, the BMW 3 series is known as the <a href="http://www.motortrend.com/cars/2010/bmw/3_series/index.html" target="_blank">hands down segment leader by Motor Trend</a>. I guess it’s not that impressive of a luxury sedan.</p>
<p><strong>How did they miss the mark?</strong></p>
<p>Well lets see what others are saying:</p>
<blockquote><p>“In its highest trims, however, the CC is more expensive than some editions of the BMW 3-Series or Infiniti G37 – cars that run circles around VW’s effort on the track and carry luxury car cachet.“     <br /><a href="http://usnews.rankingsandreviews.com/cars-trucks/Volkswagen_CC/">http://usnews.rankingsandreviews.com/cars-trucks/Volkswagen_CC/</a></p>
</blockquote>
<blockquote><p>“We must conclude that despite its similarity to the far pricier CLS, the $42,630 CC is too expensive to be considered a value-even against a Benz.” — <a href="http://www.caranddriver.com/reviews/hot_lists/high_performance/vw_audi_central/2009_volkswagen_cc_3_6_4motion_short_take_road_test">Car and Driver</a></p>
</blockquote>
<blockquote><p>“Volkswagen blurs the semantic distinction between coupe and sedan, but at $42,650 (almost) fully equipped, we call it overpriced…For the kind of money you could spend on a V6-powered CC, you could haggle your way into a pretty decent BMW, for instance, or drive off in a platinum-plated, mink-upholstered Cadillac CTS with enough left over to buy a Vespa.” — <a href="http://articles.latimes.com/2009/jan/02/business/fi-neil2">Los Angeles Times</a></p>
</blockquote>
<blockquote><p>“Not only one expensive Volkswagen, but an expensive sedan among its peers. The 6-cylinder model is priced well above a comparably equipped Mazda 6 or Nissan Maxima, and within sight of rear- or all-wheel-drive competitors from the market’s most highfalutin brands.” — <a href="http://www.nytimes.com/2009/03/15/automobiles/autoreviews/15volkswagen-cc.html">New York Times</a></p>
</blockquote>
<blockquote><p>“Nevertheless, if a serious sport sedan is what you seek, the Subaru WRX will clobber the CC every time at roughly the same price point.” <a href="http://www.motortrend.com/roadtests/sedans/1007_2010_volkswagen_cc_sport_test/performance.html">MotorTrend</a></p>
<p>&#160;</p>
</blockquote>
<p><strong>My Final Thoughts:</strong></p>
<p>I still firmly believe that the Volkswagen missed the mark with the Passat CC in many ways. If it were a two door vehicle the rear seat configuration might make a little more sense, but it’s not. If it had a retractable sunroof it would make the headroom issue go away, but it doesn’t. If it was priced like other midsized sedans I would have given it serious consideration, and it wasn’t. If it has an impressive supercharged VR6 engine like the S4, I would have paid $40,000+ to get it, but it didn’t.</p>
<p>I can’t begin to tell you how awesome the exterior looks on this vehicle, but its extremely disappointing on the inside. If I were Volkswagen, I would take a serious look at their placement in the market and realize that they need to stick to either a mid-size sedan or a luxury midsize sedan. </p>
<p>Midsize Market Failures:</p>
<p>- Lower the cost of the vehicle</p>
<p>- Add that fifth seat that is rumored</p>
<p>- Add the Panoramic Sunroof as a standard feature (done)</p>
<p>- Reduce the cost of the tech navigation package.</p>
<p>- Offer a STANDARD 100,000 mile Power Train Warranty</p>
<p>- Offer a STANDARD 50,000 mile Bumper to Bumper Warranty</p>
<p>Luxury Market Failures:</p>
<p>- Performance is needed to keep up with the 300+ HP engines. It would make this car competitive with the Ford Taurus SHO and other Performance Luxury Sedans.</p>
<p>- Increase top speed stability over 130MPH.</p>
<p>- Chrome everything should be Standard.</p>
<p>- Rear side airbag should be Standard.</p>
<p>- Bi-Xenon Headlamps should be Standard.</p>
<p>- Run flat tires should be Standard.</p>
<p>- Front and rear park distance Standard.</p>
<p>- Better Voice Command System.</p>
<p>- Motorized side-mirrors.</p>
<p>- Upgrade the interior with different shifting mechanism, leather dash, electronic rear temperature controls, rear media upgrades, cooled seats, etc etc (its this kind of stuff that someone with money and wants a luxury sedan likes. Its the features we can show our friends like look at what my car can do that yours can’t). </p>
<p>&#160;</p>
<p><strong>End Result:</strong> EPIC FAILURE.</p>
<p><strong>Updated End Result:</strong> Still Fails all of my points.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/456/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/456/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/456/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=456&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2010/02/23/2010-volkswagen-cc-review-a-test-drive-bashing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/02/cc09scr_3qtr_performance_800x600_thumb.jpg" medium="image">
			<media:title type="html">cc09scr_3qtr_performance_800x600</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/02/cc10scr_steeringwheel_800x600_thumb.jpg" medium="image">
			<media:title type="html">cc10scr_steeringwheel_800x600</media:title>
		</media:content>

		<media:content url="http://brentblawat.files.wordpress.com/2010/02/pas10scr_steeringwheel_i01_800x600_thumb.jpg" medium="image">
			<media:title type="html">pas10scr_steeringWheel_i01_800x600</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerShell Script: Retrieving Distinguished name (DN) from A Fully Qualified Domain Name (FQDN)</title>
		<link>http://bittangents.com/2010/02/22/powershell-script-retrieving-distinguished-name-dn-from-a-fully-qualified-domain-name-fqdn/</link>
		<comments>http://bittangents.com/2010/02/22/powershell-script-retrieving-distinguished-name-dn-from-a-fully-qualified-domain-name-fqdn/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 19:49:40 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Powershell Tangents]]></category>

		<guid isPermaLink="false">http://brentblawat.wordpress.com/2010/02/22/powershell-script-retrieving-distinguished-name-dn-from-a-fully-qualified-domain-name-fqdn/</guid>
		<description><![CDATA[By: Brenton Blawat While there are many posts that describe the code to do this function, there aren’t many posts that provide variables with meaning or actually describe the syntax. This post describes the method by which you can retrieve a Distinguished Name from a Fully Qualified Domain Name. Quick Reference: Fully Qualified Domain Name [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=444&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>By: Brenton Blawat</strong></p>
<p>While there are many posts that describe the code to do this function, there aren’t many posts that provide variables with meaning or actually describe the syntax. This post describes the method by which you can retrieve a Distinguished Name from a Fully Qualified Domain Name. </p>
<p><u>Quick Reference:</u> </p>
<p>Fully Qualified Domain Name (FQDN): division.domain.root</p>
<p>Distinguished Name (DC): DC=division,DC=Domain,DC=root</p>
<p>Canonical Name(CN): division.domain.root/OrganizationalUnit/</p>
<p>If you are looking for a quick way to obtain a Distinguished Name or Fully Qualified Domain Name <a href="http://brentblawat.wordpress.com/2010/02/22/powershell-script-distinguished-name-fully-qualified-domain-name-to-string/">See this article.</a></p>
<p>&#160;</p>
<h2>Mr. Weaver’s Code</h2>
<p>Mark A. Weaver’s post <a href="http://vmweaver.com/index.php/2009/08/powershell-recursive-group-membership/">Powershell – Recursive Group Membership</a>, he describes the methods by which you can convert to and from multiple variables. Here is how Mr. Weaver performs the conversion operation:</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.86%;font-family:&#39;direction:ltr;height:210px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#0000ff;">function</span> Convert-DNStoDN ($DNSName)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>    <span style="color:#008000;">#  Create an array of each item in the string separated by &quot;.&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span>    $DNSArray = $DNSName.Split(<span style="color:#006080;">&quot;.&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span>   <span style="color:#008000;"># Let's go through our new array and do something with each item</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>    <span style="color:#0000ff;">for</span> ($x = 0; $x <span style="color:#cc6633;">-lt</span> $DNSArray.Length ; $x++)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span>       {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span>         <span style="color:#008000;">#I don't want a comma after my last item, so check to see if I am on my last one and set</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span>         <span style="color:#008000;"># $Separator equal to nothing.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span>         <span style="color:#008000;"># Remember that we need to go to Length-1 because arrays are &quot;0 based indexes&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span>          <span style="color:#0000ff;">if</span> ($x <span style="color:#cc6633;">-eq</span> ($DNSArray.Length - 1)){$Separator = <span style="color:#006080;">&quot;&quot;</span>}<span style="color:#0000ff;">else</span>{$Separator =<span style="color:#006080;">&quot;,&quot;</span>}</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span>          [string]$DN += <span style="color:#006080;">&quot;DC=&quot;</span> + $DNSArray[$x] + $Separator</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span>       }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span>    <span style="color:#0000ff;">return</span> $DN</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span> }</pre>
<p><!--CRLF--></div>
</div>
<h2>My Code &#8211; Explained</h2>
<p>While my code is almost identical to Mr. Weaver’s Code, my only criticism is not providing useful variables and describing the functions. I can state, however, Mr. Weaver’s code provided a platform for a function that I use in a large production environment. I took the liberty to optimize the code (slightly) to meet my needs (Thank you sir!).</p>
<p><strong>My Function looks like: <a href="http://www.brentblawat.com/blog/codesnippets/FQDN_DN.PS1">Download PS1 Here</a></strong></p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;height:172px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#0000ff;">function</span> Get-Domain {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span>     </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>     <span style="color:#008000;">#Retrieve the Fully Qualified Domain Name if one is not supplied</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum4">   4:</span>     <span style="color:#008000;"># division.domain.root</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum5">   5:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum6">   6:</span>     <span style="color:#0000ff;">if</span> ($FQDN <span style="color:#cc6633;">-eq</span> <span style="color:#006080;">&quot;&quot;</span>) {</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum7">   7:</span>         [String]$fqdn = [System.DirectoryServices.ActiveDirectory.Domain]::getcurrentdomain()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum8">   8:</span>     }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum9">   9:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum10">  10:</span>     <span style="color:#008000;"># Create a New Array 'Item' for each item in between the '.' characters</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum11">  11:</span>     <span style="color:#008000;"># Arrayitem1 division</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum12">  12:</span>     <span style="color:#008000;"># Arrayitem2 domain</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum13">  13:</span>     <span style="color:#008000;"># Arrayitem3 root</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum14">  14:</span>     $FQDNArray = $FQDN.split(<span style="color:#006080;">&quot;.&quot;</span>)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum15">  15:</span>     </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum16">  16:</span>     <span style="color:#008000;"># Add A Separator of ','</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum17">  17:</span>     $Separator = <span style="color:#006080;">&quot;,&quot;</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum18">  18:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum19">  19:</span>     <span style="color:#008000;"># For Each Item in the Array</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum20">  20:</span>     <span style="color:#008000;"># for (CreateVar; Condition; RepeatAction)</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum21">  21:</span>     <span style="color:#008000;"># for ($x is now equal to 0; while $x is less than total array length; add 1 to X</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum22">  22:</span>     <span style="color:#0000ff;">for</span> ($x = 0; $x <span style="color:#cc6633;">-lt</span> $FQDNArray.Length ; $x++)</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum23">  23:</span>         { </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum24">  24:</span>&#160; </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum25">  25:</span>         <span style="color:#008000;">#If it's the last item in the array don't append a ','</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum26">  26:</span>         <span style="color:#0000ff;">if</span> ($x <span style="color:#cc6633;">-eq</span> ($FQDNArray.Length - 1)) { $Separator = <span style="color:#006080;">&quot;&quot;</span> }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum27">  27:</span>         </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum28">  28:</span>         <span style="color:#008000;"># Append to $DN DC= plus the array item with a separator after</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum29">  29:</span>         [string]$DN += <span style="color:#006080;">&quot;DC=&quot;</span> + $FQDNArray[$x] + $Separator</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum30">  30:</span>         </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum31">  31:</span>         <span style="color:#008000;"># continue to next item in the array</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum32">  32:</span>         }</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum33">  33:</span>     </pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum34">  34:</span>     <span style="color:#008000;">#return the Distinguished Name</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum35">  35:</span>     <span style="color:#0000ff;">return</span> $DN</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum36">  36:</span> }</pre>
<p><!--CRLF--></div>
</div>
<p><strong>To use the Function </strong>to get the Distinguished Name of the Domain:</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.33%;font-family:&#39;direction:ltr;height:39px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># Store the distinguished name in a variable named $objCrntDN.</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> $objCrntDN = Get-Domain</pre>
<p><!--CRLF--></div>
</div>
<p><strong>To use the function </strong>to get the Distinguished Name From a Fully Qualified Domain Name:</p>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.1%;font-family:&#39;direction:ltr;height:79px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># Store the distinguished name in a variable named $objCrntDN</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> <span style="color:#008000;"># Pass the Fully Qualified Domain Name with call</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span> $objCrntDN = Get-Domain division.domain.root </pre>
<p><!--CRLF--></div>
</div>
<p><strong>Note: </strong>This function also works if you place the division.domain.root in parentheses with quotations:</p>
<p><strong>Get-Domain(“division.domain.root”)</strong></p>
<h2>&#160;</h2>
<h2>What’s Different??</h2>
<p>While the output is basically the same, I’ve made a few changes in the code:</p>
<ol>
<li>“DNSname” is technically inaccurate, while I understand what he is meaning. He is referring to is the FQDN – a point of confusion for the readers. </li>
<li>I made the passing of a FQDN (optional) – as sometimes we don’t need to determine the FQDN (outside the function) before we get the Distinguished Name. </li>
<li>I named my function ‘Get-Domain’ . DNS-DN is a very specific function. Your will see that Marc has to call three different functions to convert between each of these. I chose to make a single function, and establish what the ultimate output will be. Name the function what you are getting or creating with the function. Get-Domain –&gt; You already know what the output will be &#8212; the Domain. </li>
<li>I removed the <em>Else { $separator }</em> out of the loop. In batch processing such as PowerShell, the interpreter will replace the $separator variable each time it passes through the loop for the items in the array. To make the code more efficient, I set the variable outside the loop as it only gets changed for the last array evaluation.</li>
</ol>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/444/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/444/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/444/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=444&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2010/02/22/powershell-script-retrieving-distinguished-name-dn-from-a-fully-qualified-domain-name-fqdn/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>
	</item>
		<item>
		<title>PowerShell Script: Distinguished Name / Fully Qualified Domain Name to string</title>
		<link>http://bittangents.com/2010/02/22/powershell-script-distinguished-name-fully-qualified-domain-name-to-string/</link>
		<comments>http://bittangents.com/2010/02/22/powershell-script-distinguished-name-fully-qualified-domain-name-to-string/#comments</comments>
		<pubDate>Mon, 22 Feb 2010 19:39:24 +0000</pubDate>
		<dc:creator>brentblawat</dc:creator>
				<category><![CDATA[Powershell Tangents]]></category>

		<guid isPermaLink="false">http://brentblawat.wordpress.com/2010/02/22/powershell-script-distinguished-name-fully-qualified-domain-name-to-string/</guid>
		<description><![CDATA[By: Brenton Blawat This article is designed to be short and sweet. This article displays the method by which one would retrieve the FQDN or Distinguished Name of the Domain. This is code is very useful for any operations in Active Directory. A must know for any scripter that needs to call the domain on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=443&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[</p>
<p><strong>By: Brenton Blawat</strong></p>
<p>This article is designed to be short and sweet. This article displays the method by which one would retrieve the FQDN or Distinguished Name of the Domain. This is code is very useful for any operations in Active Directory. A must know for any scripter that needs to call the domain on a system without hard coding the value in the script.</p>
<p>Lets take a theoretical network that consists of ‘division’ subdomain, ‘domain’ as the domain, and ‘root’ as the domain root.</p>
<h2>Root Distinguished name &#8211; Easy Method in PowerShell</h2>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;height:68px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># Instantiate The ADSI Provider</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> $root = [ADSI]<span style="color:#006080;">''</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span> $CurrentDN = $root.DistinguishedName</pre>
<p><!--CRLF--></div>
</div>
<p><strong>Result:</strong> </p>
<p>The variable $CurrentDN will contain:</p>
<p>DN=division,DN=domain,DN=root</p>
<p>E.G. DN=bittangents,DN=com</p>
<h2>Root Fully Qualified Domain Name (FQDN) – Easy Method In PowerShell</h2>
<div style="border-bottom:silver 1px solid;text-align:left;border-left:silver 1px solid;line-height:12pt;background-color:#f4f4f4;width:97.5%;font-family:&#39;direction:ltr;height:67px;max-height:200px;font-size:8pt;overflow:auto;border-top:silver 1px solid;cursor:text;border-right:silver 1px solid;margin:20px 0 10px;padding:4px;" id="codeSnippetWrapper">
<div style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;padding:0;" id="codeSnippet">
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum1">   1:</span> <span style="color:#008000;"># Retrieve the Fully Qualified Domain Name and store it in $FQDN Variable</span></pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:#f4f4f4;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum2">   2:</span> [String]$FQDN =  [System.DirectoryServices.ActiveDirectory.Domain]::getCurrentDomain()</pre>
<p><!--CRLF--></p>
<pre style="text-align:left;line-height:12pt;background-color:white;width:100%;font-family:&#39;direction:ltr;color:black;font-size:8pt;overflow:visible;border-style:none;margin:0;padding:0;"><span style="color:#606060;" id="lnum3">   3:</span>&#160; </pre>
<p><!--CRLF--></div>
</div>
<p><strong>Result:</strong> </p>
<p>The variable $FQDN will contain:</p>
<p>division.domain.root</p>
<p>E.G. bittangents.com</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/brentblawat.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/brentblawat.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/brentblawat.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/brentblawat.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/brentblawat.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/brentblawat.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/brentblawat.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/brentblawat.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/brentblawat.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/brentblawat.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/brentblawat.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/brentblawat.wordpress.com/443/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/brentblawat.wordpress.com/443/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/brentblawat.wordpress.com/443/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=bittangents.com&amp;blog=4066351&amp;post=443&amp;subd=brentblawat&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://bittangents.com/2010/02/22/powershell-script-distinguished-name-fully-qualified-domain-name-to-string/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/2fd28fc9e2db7e469f8237a6d55fba2b?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">brentblawat</media:title>
		</media:content>
	</item>
	</channel>
</rss>
