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

<channel>
	<title>Dalle &#38; DXter &#187; OU</title>
	<atom:link href="http://poweradmin.se/blog/tag/ou/feed/" rel="self" type="application/rss+xml" />
	<link>http://poweradmin.se/blog</link>
	<description>The Power Administrators</description>
	<lastBuildDate>Wed, 04 Jan 2012 18:18:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=</generator>
		<item>
		<title>Create Lab AD &#8211; Part 5 (Changed)</title>
		<link>http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5-changed/</link>
		<comments>http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5-changed/#comments</comments>
		<pubDate>Mon, 21 Dec 2009 06:18:19 +0000</pubDate>
		<dc:creator>Dalle</dc:creator>
				<category><![CDATA[PowerShell Blogs]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[OU]]></category>

		<guid isPermaLink="false">http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5-changed/</guid>
		<description><![CDATA[I have been doing some changes to the last part. All of my scripts are under constantly changes. So before I post the next part of the script I want to post this change. I have been doing some changes &#8230; <a href="http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5-changed/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fpoweradmin.se%252Fblog%252F2009%252F12%252F21%252Fcreate-lab-ad-part-5-changed%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Create%20Lab%20AD%20%26%238211%3B%20Part%205%20%28Changed%29%22%20%7D);"></div>
<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p><span style="color: #008000"><font color="#000000">I have been doing some changes to the last part.</font></span></p>
<p> <span style="color: #008000"><font color="#000000">
<p><span style="color: #008000"><font color="#000000">All of my scripts are under constantly changes.</font></span></p>
<p>   </font></span>
<p><span style="color: #008000"><font color="#000000">So before I post the next part of the script I</font></span></p>
<p> <span style="color: #008000"><font color="#000000">
<p><span style="color: #008000"><font color="#000000">want to post this change.</font></span></p>
<p>   </font></span>
<p><span style="color: #008000"><font color="#000000">I have been doing some changes to the $labDomain.</font></span></p>
<p> <span style="color: #008000"><font color="#000000">
<p><span style="color: #008000"><font color="#000000">Now, by default you don’t need to do change anything.</font></span></p>
<p>   </font></span>
<p><span style="color: #008000"><font color="#000000">It uses your users default domain and will use It all</font></span></p>
<p> <span style="color: #008000"><font color="#000000">
<p><span style="color: #008000"><font color="#000000">the way.</font></span></p>
<p>   </font></span>
<pre><span style="color: #008000">#</span><span style="color: #008000"> Name of the AD</span><span style="color: #008000">
#</span><span style="color: #008000"> Default is the domain where your user are.</span><span style="color: #008000">
#</span><span style="color: #008000"> Change $labDomain if you want to change this.</span><span style="color: #008000">
#</span><span style="color: #008000"> $labDomain = &quot;dc=poweradmin,dc=local&quot;</span><span style="color: #008000">
</span><span style="color: #800080">$activeLabDomain</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #5f9ea0; font-weight: bold">new-object</span><span style="color: #000000"> </span><span style="color: #800000">DirectoryServices.DirectoryEntry</span><span style="color: #000000">
</span><span style="color: #800080">$labDomain</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$activeLabDomain</span><span style="color: #000000">.distinguishedName
</span></pre>
<pre><span style="color: #008000">#</span><span style="color: #008000"> Creating the &quot;root&quot; Lab OU</span><span style="color: #008000">
</span><span style="color: #800080">$search</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">System.DirectoryServices.DirectorySearcher</span><span style="color: #000000">]</span><span style="color: #800000">&quot;</span><span style="color: #800000">[ADSI]LDAP://$labDomain</span><span style="color: #800000">&quot;</span><span style="color: #000000">
</span><span style="color: #800080">$search</span><span style="color: #000000">.Filter </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">(&amp;(name=$labOU)(objectCategory=organizationalunit))</span><span style="color: #800000">&quot;</span><span style="color: #000000">
</span><span style="color: #800080">$result</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$search</span><span style="color: #000000">.FindOne()

</span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #800080">$result</span><span style="color: #000000"> </span><span style="color: #ff0000">-eq</span><span style="color: #000000"> </span><span style="color: #800080">$null</span><span style="color: #000000">) {
    </span><span style="color: #800080">$labADSIDomain</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">ADSI</span><span style="color: #000000">]</span><span style="color: #800000">&quot;</span><span style="color: #800000">LDAP://$labDomain</span><span style="color: #800000">&quot;</span><span style="color: #000000">
    </span><span style="color: #800080">$objOU</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$labADSIDomain</span><span style="color: #000000">.Create(</span><span style="color: #800000">&quot;</span><span style="color: #800000">OrganizationalUnit</span><span style="color: #800000">&quot;</span><span style="color: #000000">, </span><span style="color: #800000">&quot;</span><span style="color: #800000">ou=</span><span style="color: #800000">&quot;</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$labOU</span><span style="color: #000000">)
    </span><span style="color: #800080">$objOU</span><span style="color: #000000">.SetInfo()
    </span><span style="color: #5f9ea0; font-weight: bold">Write-Host</span><span style="color: #000000"> </span><span style="color: #800080">$labOU</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">created</span><span style="color: #800000">&quot;</span><span style="color: #000000">
}
</span><span style="color: #0000ff">else</span><span style="color: #000000">
{
    </span><span style="color: #5f9ea0; font-weight: bold">Write-Host</span><span style="color: #000000"> </span><span style="color: #800080">$labOU</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">exists</span><span style="color: #800000">&quot;</span><span style="color: #000000">
}

</span><span style="color: #008000">#</span><span style="color: #008000"> Creating all OUs in the Lab OU</span><span style="color: #008000">
</span><span style="color: #800080">$labDomainOU</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">ADSI</span><span style="color: #000000">]</span><span style="color: #800000">&quot;</span><span style="color: #800000">LDAP://ou=$labOU,$labDomain</span><span style="color: #800000">&quot;</span><span style="color: #000000">
</span><span style="color: #0000ff">foreach</span><span style="color: #000000"> (</span><span style="color: #800080">$labUnit</span><span style="color: #000000"> </span><span style="color: #0000ff">in</span><span style="color: #000000"> </span><span style="color: #800080">$labOUs</span><span style="color: #000000">) {
    </span><span style="color: #800080">$search</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">System.DirectoryServices.DirectorySearcher</span><span style="color: #000000">]</span><span style="color: #800080">$labDomainOU</span><span style="color: #000000">
    </span><span style="color: #800080">$search</span><span style="color: #000000">.Filter </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">(&amp;(name=$labUnit)(objectCategory=organizationalunit))</span><span style="color: #800000">&quot;</span><span style="color: #000000">
    </span><span style="color: #800080">$result</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$search</span><span style="color: #000000">.FindOne()
    </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #800080">$result</span><span style="color: #000000"> </span><span style="color: #ff0000">-eq</span><span style="color: #000000"> </span><span style="color: #800080">$null</span><span style="color: #000000">) {
        </span><span style="color: #800080">$objOU</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$labDomainOU</span><span style="color: #000000">.Create(</span><span style="color: #800000">&quot;</span><span style="color: #800000">OrganizationalUnit</span><span style="color: #800000">&quot;</span><span style="color: #000000">, </span><span style="color: #800000">&quot;</span><span style="color: #800000">ou=</span><span style="color: #800000">&quot;</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$labUnit</span><span style="color: #000000">)
        </span><span style="color: #800080">$objOU</span><span style="color: #000000">.SetInfo()

        </span><span style="color: #5f9ea0; font-weight: bold">Write-Host</span><span style="color: #000000"> </span><span style="color: #800080">$labUnit</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">created</span><span style="color: #800000">&quot;</span><span style="color: #000000">
    }
    </span><span style="color: #0000ff">else</span><span style="color: #000000">
    {
        </span><span style="color: #5f9ea0; font-weight: bold">Write-Host</span><span style="color: #000000"> </span><span style="color: #800080">$labUnit</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">exists</span><span style="color: #800000">&quot;</span><span style="color: #000000">
    }

}
</span></pre>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:75bb0f60-193d-4150-8c3a-5a9c180e3451" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/powershell" rel="tag">powershell</a>,<a href="http://technorati.com/tags/Active+Directory" rel="tag">Active Directory</a>,<a href="http://technorati.com/tags/LDAP" rel="tag">LDAP</a>,<a href="http://technorati.com/tags/OU" rel="tag">OU</a></div>
<div class="shr-publisher-1233"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:60px;'><a class='shareaholic-fblike' data-shr_layout='box_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fpoweradmin.se%2Fblog%2F2009%2F12%2F21%2Fcreate-lab-ad-part-5-changed%2F' data-shr_title='Create+Lab+AD+%26%238211%3B+Part+5+%28Changed%29'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fpoweradmin.se%2Fblog%2F2009%2F12%2F21%2Fcreate-lab-ad-part-5-changed%2F'></a><a class='shareaholic-googleplusone' data-shr_size='tall' data-shr_count='true' data-shr_href='http%3A%2F%2Fpoweradmin.se%2Fblog%2F2009%2F12%2F21%2Fcreate-lab-ad-part-5-changed%2F' data-shr_title='Create+Lab+AD+%26%238211%3B+Part+5+%28Changed%29'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5-changed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create Lab AD &#8211; part 5</title>
		<link>http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5/</link>
		<comments>http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5/#comments</comments>
		<pubDate>Sun, 20 Dec 2009 23:34:41 +0000</pubDate>
		<dc:creator>Dalle</dc:creator>
				<category><![CDATA[PowerShell Blogs]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Create]]></category>
		<category><![CDATA[Lab AD]]></category>
		<category><![CDATA[Organizational Unit]]></category>
		<category><![CDATA[OU]]></category>

		<guid isPermaLink="false">http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5/</guid>
		<description><![CDATA[It’s time to take our information and create the AD. First of all we need to setup the lab structure in our AD. I use my lab active directory named poweradmin.local # Name of the AD $labDomain = [ADSI]&#34;LDAP://dc=poweradmin,dc=local&#34; And &#8230; <a href="http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fpoweradmin.se%252Fblog%252F2009%252F12%252F21%252Fcreate-lab-ad-part-5%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Create%20Lab%20AD%20%26%238211%3B%20part%205%22%20%7D);"></div>
<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>It’s time to take our information and create the AD.   <br />First of all we need to setup the lab structure in our AD.    <br />I use my lab active directory named poweradmin.local</p>
<pre><span style="color: #008000">#</span><span style="color: #008000"> Name of the AD</span><span style="color: #008000">
</span><span style="color: #800080">$labDomain</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">ADSI</span><span style="color: #000000">]</span><span style="color: #800000">&quot;</span><span style="color: #800000">LDAP://dc=poweradmin,dc=local</span><span style="color: #800000">&quot;</span></pre>
<p>And then we need to decide what our Lab OU “root” should be called.</p>
<p>&#160;<span style="color: #000000"><br />
    <br /></span><span style="color: #008000">#</span><span style="color: #008000"> LAB OU<br />
    <br /></span><span style="color: #800080">$labOU</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">Lab OU</span><span style="color: #800000">&quot;</span><span style="color: #000000"><br />
    <br /></span><span style="color: #000000"></span></p>
<p><span style="color: #000000">And then we put all of our OUs that we need.<br />
    <br /></span><span style="color: #008000">#</span><span style="color: #008000"> OUs to create<br />
    <br /></span><span style="color: #800080">$labOUs</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">Finance</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">IT</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">Marketing</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">Operations</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">Service</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">Customer Support</span><span style="color: #800000">&quot;</span><span style="color: #000000"><br />
    <br /></span></p>
<p><span style="color: #000000">Now It’s time to create the “root” lab OU.<br />
    <br /></span><span style="color: #000000">First of all we check If it exists and It doesn&#8217;t we create it.</span></p>
<p><span style="color: #000000">&#160; <br /></span><span style="color: #008000">#</span><span style="color: #008000"> Creating the &quot;root&quot; Lab OU</span><span style="color: #008000"><br />
    <br /></span><span style="color: #800080">$search</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">System.DirectoryServices.DirectorySearcher</span><span style="color: #000000">]</span><span style="color: #800080">$labDomain</span><span style="color: #000000"><br />
    <br /></span><span style="color: #800080">$search</span><span style="color: #000000">.Filter</span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">(&amp;(name=$labOU)(objectCategory=organizationalunit))</span><span style="color: #800000">&quot;</span><span style="color: #000000"><br />
    <br /></span><span style="color: #800080">$result</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$search</span><span style="color: #000000">.FindOne()</p>
<p></span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #800080">$result</span><span style="color: #000000"> </span><span style="color: #ff0000">-eq</span><span style="color: #000000"> </span><span style="color: #800080">$null</span><span style="color: #000000">) {</p>
<p>&#160;&#160; </span><span style="color: #800080">$objOU</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$labDomain</span><span style="color: #000000">.Create(</span><span style="color: #800000">&quot;</span><span style="color: #800000">OrganizationalUnit</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">ou=</span><span style="color: #800000">&quot;</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$labOU</span><span style="color: #000000">)<br />
    <br />&#160;&#160; </span><span style="color: #800080">$objOU</span><span style="color: #000000">.SetInfo()<br />
    <br />&#160;&#160; </span><span style="color: #5f9ea0; font-weight: bold">Write-Host</span><span style="color: #000000"> </span><span style="color: #800080">$labOU</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">created</span><span style="color: #800000">&quot;</span><span style="color: #000000"><br />
    <br />}</p>
<p></span><span style="color: #0000ff">else</span><span style="color: #000000"><br />
    <br />{</p>
<p>&#160;&#160; </span><span style="color: #5f9ea0; font-weight: bold">Write-Host</span><span style="color: #000000"> </span><span style="color: #800080">$labOU</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">exists</span><span style="color: #800000">&quot;</span><span style="color: #000000"><br />
    <br />}</p>
<p></span><span style="color: #008000"><font color="#000000">When we have the “root” OU setup It’s time to create the rest.</font></span></p>
<p><span style="color: #008000">#</span><span style="color: #008000"> Creating all OUs in the Lab OU</span><span style="color: #008000"><br />
    <br /></span><span style="color: #800080">$labDomainOU</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">ADSI</span><span style="color: #000000">]</span><span style="color: #800000">&quot;</span><span style="color: #800000">LDAP://ou=$labOU,dc=poweradmin,dc=local</span><span style="color: #800000">&quot;</span><span style="color: #000000"><br />
    <br /></span><span style="color: #0000ff">foreach</span><span style="color: #000000"> (</span><span style="color: #800080">$labUnit</span><span style="color: #000000"> </span><span style="color: #0000ff">in</span><span style="color: #000000"> </span><span style="color: #800080">$labOUs</span><span style="color: #000000">) {<br />
    <br />&#160;&#160; </span><span style="color: #800080">$search</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> [</span><span style="color: #008080">System.DirectoryServices.DirectorySearcher</span><span style="color: #000000">]</span><span style="color: #800080">$labDomainOU</span><span style="color: #000000"><br />
    <br />&#160;&#160; </span><span style="color: #800080">$search</span><span style="color: #000000">.Filter</span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">(&amp;(name=$labUnit)(objectCategory=organizationalunit))</span><span style="color: #800000">&quot;</span><span style="color: #000000"><br />
    <br />&#160;&#160; </span><span style="color: #800080">$result</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$search</span><span style="color: #000000">.FindOne()<br />
    <br />&#160;&#160; </span><span style="color: #0000ff">if</span><span style="color: #000000"> (</span><span style="color: #800080">$result</span><span style="color: #000000"> </span><span style="color: #ff0000">-eq</span><span style="color: #000000"> </span><span style="color: #800080">$null</span><span style="color: #000000">) {<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #800080">$objOU</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$labDomainOU</span><span style="color: #000000">.Create(</span><span style="color: #800000">&quot;</span><span style="color: #800000">OrganizationalUnit</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">ou=</span><span style="color: #800000">&quot;</span><span style="color: #000000"> </span><span style="color: #ff0000">+</span><span style="color: #000000"> </span><span style="color: #800080">$labUnit</span><span style="color: #000000">)<br />
    <br />&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #800080">$objOU</span><span style="color: #000000">.SetInfo()</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #5f9ea0; font-weight: bold">Write-Host</span><span style="color: #000000"> </span><span style="color: #800080">$labUnit</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">created</span><span style="color: #800000">&quot;</span><span style="color: #000000"><br />
    <br />&#160;&#160;&#160; }</p>
<p>&#160;&#160; </span><span style="color: #0000ff">else</span><span style="color: #000000"><br />
    <br />&#160;&#160;&#160; {</p>
<p>&#160;&#160;&#160;&#160;&#160;&#160; </span><span style="color: #5f9ea0; font-weight: bold">Write-Host</span><span style="color: #000000"> </span><span style="color: #800080">$labUnit</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">exists</span><span style="color: #800000">&quot;</span><span style="color: #000000"><br />
    <br />&#160;&#160;&#160; }</p>
<p>}</span></p>
<p><span style="color: #000000">It should look like this if you used the same OUs as I did.</span></p>
<p><a href="http://poweradmin.se/blog/wp-content/uploads/image256.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://poweradmin.se/blog/wp-content/uploads/image_thumb190.png" width="331" height="146" /></a> <span style="color: #000000"><br />
    <br /></span></p>
<p>In the next part we will create the users.</p>
<p>&#160;</p>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:69e14c5e-54e5-4713-842c-a2a3e552be1f" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/PowerShell" rel="tag">PowerShell</a>,<a href="http://technorati.com/tags/Active+Directory" rel="tag">Active Directory</a>,<a href="http://technorati.com/tags/OU" rel="tag">OU</a>,<a href="http://technorati.com/tags/Organizational+Unit" rel="tag">Organizational Unit</a>,<a href="http://technorati.com/tags/Create" rel="tag">Create</a>,<a href="http://technorati.com/tags/Lab+AD" rel="tag">Lab AD</a></div>
<div class="shr-publisher-1230"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:60px;'><a class='shareaholic-fblike' data-shr_layout='box_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fpoweradmin.se%2Fblog%2F2009%2F12%2F21%2Fcreate-lab-ad-part-5%2F' data-shr_title='Create+Lab+AD+%26%238211%3B+part+5'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fpoweradmin.se%2Fblog%2F2009%2F12%2F21%2Fcreate-lab-ad-part-5%2F'></a><a class='shareaholic-googleplusone' data-shr_size='tall' data-shr_count='true' data-shr_href='http%3A%2F%2Fpoweradmin.se%2Fblog%2F2009%2F12%2F21%2Fcreate-lab-ad-part-5%2F' data-shr_title='Create+Lab+AD+%26%238211%3B+part+5'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://poweradmin.se/blog/2009/12/21/create-lab-ad-part-5/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Create Lab AD &#8211; part 3</title>
		<link>http://poweradmin.se/blog/2009/12/17/create-lab-ad-part-3/</link>
		<comments>http://poweradmin.se/blog/2009/12/17/create-lab-ad-part-3/#comments</comments>
		<pubDate>Thu, 17 Dec 2009 07:16:17 +0000</pubDate>
		<dc:creator>Dalle</dc:creator>
				<category><![CDATA[PowerShell Blogs]]></category>
		<category><![CDATA[Active Directory]]></category>
		<category><![CDATA[Country]]></category>
		<category><![CDATA[OU]]></category>

		<guid isPermaLink="false">http://poweradmin.se/blog/2009/12/17/create-lab-ad-part-3/</guid>
		<description><![CDATA[We have: Real names User Names (samAccountNames) with employee numbers In this part we will do stuff for the Lab OUs and we will also pick Country for the users. We will not create anything until we have what we &#8230; <a href="http://poweradmin.se/blog/2009/12/17/create-lab-ad-part-3/">Continue reading <span class="meta-nav">&#8594;</span></a>
No related posts.]]></description>
			<content:encoded><![CDATA[
<div class="topsy_widget_data topsy_theme_blue" style="float: right;margin-left: 0.75em; background: url(data:,%7B%20%22url%22%3A%20%22http%253A%252F%252Fpoweradmin.se%252Fblog%252F2009%252F12%252F17%252Fcreate-lab-ad-part-3%252F%22%2C%20%22style%22%3A%20%22big%22%2C%20%22title%22%3A%20%22Create%20Lab%20AD%20%26%238211%3B%20part%203%22%20%7D);"></div>
<!-- Start Shareaholic LikeButtonSetTop Automatic --><!-- End Shareaholic LikeButtonSetTop Automatic --><p>We have:</p>
<ol>
<li>Real names</li>
<li>User Names (samAccountNames) with employee numbers</li>
</ol>
<p>In this part we will do stuff for the Lab OUs and we will also pick Country   <br />for the users.    </p>
<p>We will not create anything until we have what we need in information.</p>
<p><span style="color: #800080">$labOUs</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">Finance</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">IT</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">Marketing</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">Operations</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">Service</span><span style="color: #800000">&quot;</span><span style="color: #000000">,</span><span style="color: #800000">&quot;</span><span style="color: #800000">Customer Support</span><span style="color: #800000">&quot;</span></p>
<pre><span style="color: #800080">$mylabOUs</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$labOUs</span><span style="color: #000000"> | Get-Random</span></pre>
<p><span style="color: #800000"></span><span style="color: #000000"><font color="#800000"></font>The output will be one of the OUs in the $labOUs.</p>
<p>Finance</p>
<p>IT</p>
<p></span><span style="color: #000000">Marketing</p>
<p>Need more OU names, just add yours.</span></p>
<p><span style="color: #000000"></span></p>
<p><span style="color: #000000">Now It’s time to do the same way to make some countries for the users.</span></p>
<pre><span style="color: #800080">$userCountry</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800000">&quot;</span><span style="color: #800000">Sweden</span><span style="color: #800000">&quot;</span><span style="color: #000000">, </span><span style="color: #800000">&quot;</span><span style="color: #800000">Norway</span><span style="color: #800000">&quot;</span><span style="color: #000000">, </span><span style="color: #800000">&quot;</span><span style="color: #800000">Denmark</span><span style="color: #800000">&quot;</span><span style="color: #000000">, </span><span style="color: #800000">&quot;</span><span style="color: #800000">Finland</span><span style="color: #800000">&quot;</span><span style="color: #000000">
</span></pre>
<pre><span style="color: #800080">$myUserCountry</span><span style="color: #000000"> </span><span style="color: #ff0000">=</span><span style="color: #000000"> </span><span style="color: #800080">$userCountry</span><span style="color: #000000"> | Get-Random</span></pre>
<pre><span style="color: #000000"></span></pre>
<div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:0767317B-992E-4b12-91E0-4F059A8CECA8:ba670f2f-91fe-4312-a659-f674b642df44" class="wlWriterEditableSmartContent">Technorati Tags: <a href="http://technorati.com/tags/PowerShell" rel="tag">PowerShell</a>,<a href="http://technorati.com/tags/Active+Directory" rel="tag">Active Directory</a>,<a href="http://technorati.com/tags/OU" rel="tag">OU</a>,<a href="http://technorati.com/tags/Country" rel="tag">Country</a></div>
<div class="shr-publisher-1208"></div><!-- Start Shareaholic LikeButtonSetBottom Automatic --><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><div class='shareaholic-like-buttonset' style='float:none;height:60px;'><a class='shareaholic-fblike' data-shr_layout='box_count' data-shr_showfaces='false' data-shr_href='http%3A%2F%2Fpoweradmin.se%2Fblog%2F2009%2F12%2F17%2Fcreate-lab-ad-part-3%2F' data-shr_title='Create+Lab+AD+%26%238211%3B+part+3'></a><a class='shareaholic-fbsend' data-shr_href='http%3A%2F%2Fpoweradmin.se%2Fblog%2F2009%2F12%2F17%2Fcreate-lab-ad-part-3%2F'></a><a class='shareaholic-googleplusone' data-shr_size='tall' data-shr_count='true' data-shr_href='http%3A%2F%2Fpoweradmin.se%2Fblog%2F2009%2F12%2F17%2Fcreate-lab-ad-part-3%2F' data-shr_title='Create+Lab+AD+%26%238211%3B+part+3'></a></div><div style="clear: both; min-height: 1px; height: 3px; width: 100%;"></div><!-- End Shareaholic LikeButtonSetBottom Automatic -->
<p>No related posts.</p>]]></content:encoded>
			<wfw:commentRss>http://poweradmin.se/blog/2009/12/17/create-lab-ad-part-3/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

