<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	>
<channel>
	<title>Comments on: Managing Active Directory with Windows PowerShell</title>
	<atom:link href="http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.powershellpro.com</link>
	<description>Sharing the Experience</description>
	<pubDate>Wed, 07 Jan 2009 01:04:46 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.5</generator>
		<item>
		<title>By: Ryan T. Hilton</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-240</link>
		<dc:creator>Ryan T. Hilton</dc:creator>
		<pubDate>Mon, 27 Oct 2008 22:51:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-240</guid>
		<description>This would work for GaryM's question:

$Search = New-Object DirectoryServices.DirectorySearcher([ADSI]“”)
$Search.filter = “(&#38;(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))”
$Search.PageSize = 1000
[void]$Search.PropertiesToLoad.Add("cn");
[void]$Search.PropertiesToLoad.Add("distinguishedname");

$results = $Search.Findall()
$results &#124; select @{e={$_.properties.cn};n='name'},@{e={$_.properties.distinguishedname};n='distinguishedname'}</description>
		<content:encoded><![CDATA[<p>This would work for GaryM&#8217;s question:</p>
<p>$Search = New-Object DirectoryServices.DirectorySearcher([ADSI]“”)<br />
$Search.filter = “(&amp;(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))”<br />
$Search.PageSize = 1000<br />
[void]$Search.PropertiesToLoad.Add(&#8221;cn&#8221;);<br />
[void]$Search.PropertiesToLoad.Add(&#8221;distinguishedname&#8221;);</p>
<p>$results = $Search.Findall()<br />
$results | select @{e={$_.properties.cn};n=&#8217;name&#8217;},@{e={$_.properties.distinguishedname};n=&#8217;distinguishedname&#8217;}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ryan T. Hilton</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-239</link>
		<dc:creator>Ryan T. Hilton</dc:creator>
		<pubDate>Mon, 27 Oct 2008 22:13:48 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-239</guid>
		<description>GaryM,
I know that this does not answer your question, but from my experience your query would require 1001 connections to the DC to perform the lookups. Once to perform the search and 1000 times to retrieve the DirectoryEntry of each user. You would be better off using the $Search.PropertiesToLoad.Add method to specify 'cn' and 'distinguishedname'.

You could then use $User = $result.Properties followed by $User.cn, $User.distinguishedname

As your PageSize grows this can cause some huge overhead.</description>
		<content:encoded><![CDATA[<p>GaryM,<br />
I know that this does not answer your question, but from my experience your query would require 1001 connections to the DC to perform the lookups. Once to perform the search and 1000 times to retrieve the DirectoryEntry of each user. You would be better off using the $Search.PropertiesToLoad.Add method to specify &#8216;cn&#8217; and &#8216;distinguishedname&#8217;.</p>
<p>You could then use $User = $result.Properties followed by $User.cn, $User.distinguishedname</p>
<p>As your PageSize grows this can cause some huge overhead.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Norman</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-157</link>
		<dc:creator>Norman</dc:creator>
		<pubDate>Thu, 17 Jul 2008 15:14:19 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-157</guid>
		<description>Jesse-
I'm confused.  In a reply above, you say "By using [ADSI] you are telling PowerShell to use the ADSI provider, which is required…" but at the top of this tutorial, "LDAP" is described as "an ADSI provider."  So is ADSI a provider, or LDAP, or is it both in a two-level arrangement?</description>
		<content:encoded><![CDATA[<p>Jesse-<br />
I&#8217;m confused.  In a reply above, you say &#8220;By using [ADSI] you are telling PowerShell to use the ADSI provider, which is required…&#8221; but at the top of this tutorial, &#8220;LDAP&#8221; is described as &#8220;an ADSI provider.&#8221;  So is ADSI a provider, or LDAP, or is it both in a two-level arrangement?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GaryM</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-148</link>
		<dc:creator>GaryM</dc:creator>
		<pubDate>Thu, 03 Jul 2008 08:11:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-148</guid>
		<description>Jesse,

I have got the script below which outputs the two values to the screen, how can I get this to output in columns?  I have tried numerous attempts with format-table without success.

$Search = New-Object DirectoryServices.DirectorySearcher([ADSI]"")
$Search.filter = "(&#38;(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))"
$Search.PageSize = 1000
$results = $Search.Findall() 

Foreach($result in $results){
$User = $result.GetDirectoryEntry() 
$user.cn,$user.distinguishedname 
}</description>
		<content:encoded><![CDATA[<p>Jesse,</p>
<p>I have got the script below which outputs the two values to the screen, how can I get this to output in columns?  I have tried numerous attempts with format-table without success.</p>
<p>$Search = New-Object DirectoryServices.DirectorySearcher([ADSI]&#8220;&#8221;)<br />
$Search.filter = &#8220;(&amp;(objectClass=user)(userAccountControl:1.2.840.113556.1.4.803:=65536))&#8221;<br />
$Search.PageSize = 1000<br />
$results = $Search.Findall() </p>
<p>Foreach($result in $results){<br />
$User = $result.GetDirectoryEntry()<br />
$user.cn,$user.distinguishedname<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse Hamrick</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-146</link>
		<dc:creator>Jesse Hamrick</dc:creator>
		<pubDate>Tue, 01 Jul 2008 15:51:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-146</guid>
		<description>Also, Computer and Users are not OUs but Containers (That didn't hit me at the time of my reply...). Use the following when binding:
CN=Users,DC=uug,DC=vmc,DC=cc
-and-
CN=Computers...

You should be able to enumerate these containers.</description>
		<content:encoded><![CDATA[<p>Also, Computer and Users are not OUs but Containers (That didn&#8217;t hit me at the time of my reply&#8230;). Use the following when binding:<br />
CN=Users,DC=uug,DC=vmc,DC=cc<br />
-and-<br />
CN=Computers&#8230;</p>
<p>You should be able to enumerate these containers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GaryM</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-145</link>
		<dc:creator>GaryM</dc:creator>
		<pubDate>Mon, 30 Jun 2008 18:57:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-145</guid>
		<description>I think I worked it out, you cannot use this to enumerate against the default OU's Users and Computers; other OU's that have been created work fine.</description>
		<content:encoded><![CDATA[<p>I think I worked it out, you cannot use this to enumerate against the default OU&#8217;s Users and Computers; other OU&#8217;s that have been created work fine.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse Hamrick</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-144</link>
		<dc:creator>Jesse Hamrick</dc:creator>
		<pubDate>Mon, 30 Jun 2008 15:45:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-144</guid>
		<description>You are missing [ADSI] in your binding. Change your line of code to this and try again:
$Searcher.SearchRoot = [ADSI]"LDAP://OU=Users,DC=uug,DC=vmc,DC=cc"

By using [ADSI] you are telling PowerShell to use the ADSI provider, which is required...</description>
		<content:encoded><![CDATA[<p>You are missing [ADSI] in your binding. Change your line of code to this and try again:<br />
$Searcher.SearchRoot = [ADSI]&#8220;LDAP://OU=Users,DC=uug,DC=vmc,DC=cc&#8221;</p>
<p>By using [ADSI] you are telling PowerShell to use the ADSI provider, which is required&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GaryM</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-143</link>
		<dc:creator>GaryM</dc:creator>
		<pubDate>Mon, 30 Jun 2008 11:42:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-143</guid>
		<description>Jesse,

Thanks for the reply, this is beginning to make more sense.  One more question, I am able to search AD when binding to the root domain, however when trying any searches directed at specific OU's I am getting an error, even with your example scripts above.  The code I am running is: 

$searcher = new-object DirectoryServices.DirectorySearcher
$searcher.SearchRoot = "LDAP://OU=Users,DC=uug,DC=vcm,DC=cc"
$searcher.filter = "(objectClass=user)"
$Searcher.SearchScope = "OneLevel"
$searcher.findall()

and this outputs:

Exception calling "Findall" with "0" argument(s) @There is no such
object on the server."
At c:\MyScripts\test.ps1:13 char:18 + $searcher.findall &#60;&#60;&#60;&#60; ()

Can you tell me where I am going wrong.  I have tried numerous variations using different scripts from different sites without success and used different domains.</description>
		<content:encoded><![CDATA[<p>Jesse,</p>
<p>Thanks for the reply, this is beginning to make more sense.  One more question, I am able to search AD when binding to the root domain, however when trying any searches directed at specific OU&#8217;s I am getting an error, even with your example scripts above.  The code I am running is: </p>
<p>$searcher = new-object DirectoryServices.DirectorySearcher<br />
$searcher.SearchRoot = &#8220;LDAP://OU=Users,DC=uug,DC=vcm,DC=cc&#8221;<br />
$searcher.filter = &#8220;(objectClass=user)&#8221;<br />
$Searcher.SearchScope = &#8220;OneLevel&#8221;<br />
$searcher.findall()</p>
<p>and this outputs:</p>
<p>Exception calling &#8220;Findall&#8221; with &#8220;0&#8243; argument(s) @There is no such<br />
object on the server.&#8221;<br />
At c:\MyScripts\test.ps1:13 char:18 + $searcher.findall &lt;&lt;&lt;&lt; ()</p>
<p>Can you tell me where I am going wrong.  I have tried numerous variations using different scripts from different sites without success and used different domains.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jesse Hamrick</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-138</link>
		<dc:creator>Jesse Hamrick</dc:creator>
		<pubDate>Thu, 26 Jun 2008 16:09:54 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-138</guid>
		<description>Gary,
Sure... The best way to explain it is to show you where the information lives on the MSDN. This link provides answers to what you wanted to know about using Active Directory Service Interface.

http://msdn.microsoft.com/en-us/library/aa746512(VS.85).aspx</description>
		<content:encoded><![CDATA[<p>Gary,<br />
Sure&#8230; The best way to explain it is to show you where the information lives on the MSDN. This link provides answers to what you wanted to know about using Active Directory Service Interface.</p>
<p><a href="http://msdn.microsoft.com/en-us/library/aa746512" rel="nofollow">http://msdn.microsoft.com/en-us/library/aa746512</a>(VS.85).aspx</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: GaryM</title>
		<link>http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-136</link>
		<dc:creator>GaryM</dc:creator>
		<pubDate>Thu, 26 Jun 2008 12:07:33 +0000</pubDate>
		<guid isPermaLink="false">http://www.powershellpro.com/powershell-tutorial-introduction/powershell-tutorial-active-directory/#comment-136</guid>
		<description>Thank you for this set of tutorials, they have been very useful to someone who has done very little scripting.  I'm beginning to make some progress, however I'm obviously missing something.  I undertand the principal of methods however in you example script:

   $Class = "organizationalUnit"
   $OU = "OU=TestOU"

   $objADSI = [ADSI]"LDAP://DC=nwtraders,DC=msft"
   $objOU = $objADSI.create($Class, $OU)
   $objOU.setInfo()

You use the .create and .setinfo methods.  Can you explain where these come from in this example and what get-member command I would use to return this information.  Many thanks in advance</description>
		<content:encoded><![CDATA[<p>Thank you for this set of tutorials, they have been very useful to someone who has done very little scripting.  I&#8217;m beginning to make some progress, however I&#8217;m obviously missing something.  I undertand the principal of methods however in you example script:</p>
<p>   $Class = &#8220;organizationalUnit&#8221;<br />
   $OU = &#8220;OU=TestOU&#8221;</p>
<p>   $objADSI = [ADSI]&#8220;LDAP://DC=nwtraders,DC=msft&#8221;<br />
   $objOU = $objADSI.create($Class, $OU)<br />
   $objOU.setInfo()</p>
<p>You use the .create and .setinfo methods.  Can you explain where these come from in this example and what get-member command I would use to return this information.  Many thanks in advance</p>
]]></content:encoded>
	</item>
</channel>
</rss>
