You DO have those methods on a DirectorySearcher, but not on a
DirectoryEntry. What I was referring to is the [ADIS] type accelerator. In
v2 they add [ADSISearcher].
$user = [ADIS]"LDAP://USERDN"
is the same as
$user = New-Object System.DirectoryServices.DirectoryEntry("LDAP://USERDN")
To create a Searcher that WILL have findall() and getdirectoryentry().
$de = [ADSI]"LDAP://<Root of Search>" # DirectoryEntry for the root of the
search MUST HAVE
$filter = "(&()())" # LDAP Filter MUST Have
$props = @("prop1","prop2") # An array with the properties you want
returned (optional)
$searcher = New-Object System.DirectoryServices.DirectorySearcher
($de,$filter,$props)
Type Extensions
http://blogs.msdn.com/powershell/arc...24/644987.aspx
[ADSI] Accelerator
http://powershelllive.com/blogs/lunc...o-objects.aspx
Custom Type Accelerators
http://www.nivot.org/2008/03/27/Crea...owerShell.aspx
"Swamy Channaveera" <SwamyChannaveera@xxxxxx> wrote in
message news:7786CB3C-7E61-4DCE-93D1-5590878372BC@xxxxxx
| Quote: |  | |
|
> You are right There is no findall() and getdirectoryentry() method may be
> with V2 it is available.
>
>
> "Brandon Shell [MVP]" wrote:
> | Quote: |  | | |
>> not in v1 without modifying the type extensions.
>>
>> This will do what your wanting
>>
>> function Get-MyADUser($user="*"){
>> $filter = "(&(objectcategory=user)(sAMAccountName=$user)"
>> $ds = new-object
>> system.directoryservices.directorysearcher([adsi]"",$filter)
>> $ds.pagesize = 1000
>> $ds.findall() | %{$_.GetDirectoryEntry()}
>> }
>>
>> "Swamy Channaveera" <SwamyChannaveera@xxxxxx> wrote in
>> message news 3315E43-B209-4895-9422-E4381049492D@xxxxxx | Quote: |  | | |
>> > Hi,
>> >
>> > without specifying the complete DN of an object and using
>> > [ADSI]"LDAP:// "
>> > provider can i serach an object? assuming my AD has many OU and users
>> > are
>> > spread across many OU?
| | | | | >> | | | | | | |
| | |