Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - LDS query via powershell

Reply
 
Old 07-07-2008   #1 (permalink)
H4mm3r


 
 

LDS query via powershell

Hi all,

I would like to know if powershell could do a query in a LDS instance
on my localhost ?
If yes, what are the procedure to do so ?

Thanks in advance, Thomas.

My System SpecsSystem Spec
Old 07-07-2008   #2 (permalink)
Shay Levy [MVP]


 
 

Re: LDS query via powershell

Hi H4mm3r,

Like ADAM?


---
Shay Levy
Windows PowerShell MVP
blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic



H> Hi all,
H>
H> I would like to know if powershell could do a query in a LDS instance
H> on my localhost ?
H> If yes, what are the procedure to do so ?
H> Thanks in advance, Thomas.
H>


My System SpecsSystem Spec
Old 07-07-2008   #3 (permalink)
RichS [MVP]


 
 

Re: LDS query via powershell

AD Lightweight Directory Services is the new name for ADAM in Windows 2008.

Short answer is yes you can

Easiest way is to use the Quest cmdlets - there examples in the documentation

or use directorysearcher

$root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"

then create the searcher as normal




--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"Shay Levy [MVP]" wrote:
Quote:

> Hi H4mm3r,
>
> Like ADAM?
>
>
> ---
> Shay Levy
> Windows PowerShell MVP
> blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic
>
>
>
> H> Hi all,
> H>
> H> I would like to know if powershell could do a query in a LDS instance
> H> on my localhost ?
> H> If yes, what are the procedure to do so ?
> H> Thanks in advance, Thomas.
> H>
>
>
>
My System SpecsSystem Spec
Old 07-08-2008   #4 (permalink)
H4mm3r


 
 

Re: LDS query via powershell

Hi all,

Yes, ADAM has been renamed into LDS.
I did understand that Quest gives us this feature.
So, I knew about the path variable to set.
The real trouble for me is how to get the search done.
Which command should I use.
If you give me a complete example of the search of a CN from the root,
it would be great.

Thanks in advance, Thomas.

On 7 juil, 21:31, RichS [MVP] <RichS...@xxxxxx>
wrote:
Quote:

> AD Lightweight Directory Services is the new name for ADAM in Windows 2008.
>
> Short answer is yes you can
>
> Easiest way is to use the Quest cmdlets *- there examples in the documentation
>
> or use directorysearcher
>
> $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
>
> then create the searcher as normal
>
> --
> Richard Siddaway
> All scripts are supplied "as is" and with no warranty
> PowerShell MVP
> Blog:http://richardsiddaway.spaces.live.com/
> PowerShell User Group:http://www.get-psuguk.org.uk
>
> "Shay Levy [MVP]" wrote:
Quote:

> > Hi H4mm3r,
>
Quote:

> > Like ADAM?
>
Quote:

> > ---
> > Shay Levy
> > Windows PowerShell MVP
> > blog:http://blogs.microsoft.co.il/blogs/ScriptFanatic
>
Quote:

> > H> Hi all,
> > H>
> > H> I would like to know if powershell could do a query in a LDS instance
> > H> on my localhost ?
> > H> If yes, what are the procedure to do so ?
> > H> Thanks in advance, Thomas.
> > H>
My System SpecsSystem Spec
Old 07-08-2008   #5 (permalink)
RichS [MVP]


 
 

Re: LDS query via powershell

The search is the same as an AD search

$struser = "BOSCH Herbert"

$root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
$search = [System.DirectoryServices.DirectorySearcher]$root
$search.Filter = "(cn=$struser)"
$result = $search.FindOne()

if you want to work with the result you will need to do

$usr = $result.getdirectoryentry()

You can find more on LDAP filters at


http://msdn.microsoft.com/en-us/library/aa746475.aspx

--
Richard Siddaway
All scripts are supplied "as is" and with no warranty
PowerShell MVP
Blog: http://richardsiddaway.spaces.live.com/
PowerShell User Group: http://www.get-psuguk.org.uk


"H4mm3r" wrote:
Quote:

> Hi all,
>
> Yes, ADAM has been renamed into LDS.
> I did understand that Quest gives us this feature.
> So, I knew about the path variable to set.
> The real trouble for me is how to get the search done.
> Which command should I use.
> If you give me a complete example of the search of a CN from the root,
> it would be great.
>
> Thanks in advance, Thomas.
>
> On 7 juil, 21:31, RichS [MVP] <RichS...@xxxxxx>
> wrote:
Quote:

> > AD Lightweight Directory Services is the new name for ADAM in Windows 2008.
> >
> > Short answer is yes you can
> >
> > Easiest way is to use the Quest cmdlets - there examples in the documentation
> >
> > or use directorysearcher
> >
> > $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
> >
> > then create the searcher as normal
> >
> > --
> > Richard Siddaway
> > All scripts are supplied "as is" and with no warranty
> > PowerShell MVP
> > Blog:http://richardsiddaway.spaces.live.com/
> > PowerShell User Group:http://www.get-psuguk.org.uk
> >
> > "Shay Levy [MVP]" wrote:
Quote:

> > > Hi H4mm3r,
> >
Quote:

> > > Like ADAM?
> >
Quote:

> > > ---
> > > Shay Levy
> > > Windows PowerShell MVP
> > > blog:http://blogs.microsoft.co.il/blogs/ScriptFanatic
> >
Quote:

> > > H> Hi all,
> > > H>
> > > H> I would like to know if powershell could do a query in a LDS instance
> > > H> on my localhost ?
> > > H> If yes, what are the procedure to do so ?
> > > H> Thanks in advance, Thomas.
> > > H>
>
>
My System SpecsSystem Spec
Old 07-08-2008   #6 (permalink)
H4mm3r


 
 

Re: LDS query via powershell

Hi all,

Thanks for your answer.
I knew about the Quest tools.
But I don't know how to do the query into the LDS.
For example, I want ot search if a CN is in the database.

Thanks in advance, Thomas.

On 7 juil, 21:31, RichS [MVP] <RichS...@xxxxxx>
wrote:
Quote:

> AD Lightweight Directory Services is the new name for ADAM in Windows 2008.
>
> Short answer is yes you can
>
> Easiest way is to use the Quest cmdlets *- there examples in the documentation
>
> or use directorysearcher
>
> $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
>
> then create the searcher as normal
>
> --
> Richard Siddaway
> All scripts are supplied "as is" and with no warranty
> PowerShell MVP
> Blog:http://richardsiddaway.spaces.live.com/
> PowerShell User Group:http://www.get-psuguk.org.uk
>
> "Shay Levy [MVP]" wrote:
Quote:

> > Hi H4mm3r,
>
Quote:

> > Like ADAM?
>
Quote:

> > ---
> > Shay Levy
> > Windows PowerShell MVP
> > blog:http://blogs.microsoft.co.il/blogs/ScriptFanatic
>
Quote:

> > H> Hi all,
> > H>
> > H> I would like to know if powershell could do a query in a LDS instance
> > H> on my localhost ?
> > H> If yes, what are the procedure to do so ?
> > H> Thanks in advance, Thomas.
> > H>
My System SpecsSystem Spec
Old 07-08-2008   #7 (permalink)
Shay Levy [MVP]


 
 

Re: LDS query via powershell



Connect-QADService -svc "localhost:389"
Get-QADuser 'CN=Test1,CN=Users,DC=domain,DC=com'


---
Shay Levy
Windows PowerShell MVP
blog: http://blogs.microsoft.co.il/blogs/ScriptFanatic



H> Hi all,
H>
H> Thanks for your answer.
H> I knew about the Quest tools.
H> But I don't know how to do the query into the LDS.
H> For example, I want ot search if a CN is in the database.
H> Thanks in advance, Thomas.
H>
H> On 7 juil, 21:31, RichS [MVP] <RichS...@xxxxxx>
H> wrote:
H>
Quote:
Quote:

>> AD Lightweight Directory Services is the new name for ADAM in Windows
>> 2008.
>>
>> Short answer is yes you can
>>
>> Easiest way is to use the Quest cmdlets - there examples in the
>> documentation
>>
>> or use directorysearcher
>>
>> $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
>>
>> then create the searcher as normal
>>
>> --
>> Richard Siddaway
>> All scripts are supplied "as is" and with no warranty
>> PowerShell MVP
>> Blog:http://richardsiddaway.spaces.live.com/
>> PowerShell User Group:http://www.get-psuguk.org.uk
>> "Shay Levy [MVP]" wrote:
>>
Quote:

>>> Hi H4mm3r,
>>>
>>> Like ADAM?
>>>
>>> ---
>>> Shay Levy
>>> Windows PowerShell MVP
>>> blog:http://blogs.microsoft.co.il/blogs/ScriptFanatic
>>> H> Hi all,
>>> H>
>>> H> I would like to know if powershell could do a query in a LDS
>>> instance
>>> H> on my localhost ?
>>> H> If yes, what are the procedure to do so ?
>>> H> Thanks in advance, Thomas.
>>> H>

My System SpecsSystem Spec
Old 07-09-2008   #8 (permalink)
H4mm3r


 
 

Re: LDS query via powershell

Hi all,

Thanks Richard. Based on your example, I was able to make it works :
$strtofind = "youpi"
$root = [ADSI] "LDAP://localhost:389/dc=XXX,dc=YYY"
$searcher = new-object
System.DirectoryServices.DirectorySearcher($root)
$searcher.Filter = "(cn=$strtofind)"
$result = $searcher.FindAll()
echo $result

Now, I'll try to update the record. Do you know a good place for all
the basic documentation of the PowerShell language and API ?

On 8 juil, 14:39, RichS [MVP] <RichS...@xxxxxx>
wrote:
Quote:

> The search is the same as an AD search
>
> $struser = "BOSCH Herbert"
>
> $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
> $search = [System.DirectoryServices.DirectorySearcher]$root
> $search.Filter = "(cn=$struser)"
> $result = $search.FindOne()
>
> if you want to work with the result *you will need to do
>
> $usr = $result.getdirectoryentry()
>
> You can find more on LDAP filters at
>
> http://msdn.microsoft.com/en-us/library/aa746475.aspx
>
> --
> Richard Siddaway
> All scripts are supplied "as is" and with no warranty
> PowerShell MVP
> Blog:http://richardsiddaway.spaces.live.com/
> PowerShell User Group:http://www.get-psuguk.org.uk
>
> "H4mm3r" wrote:
Quote:

> > Hi all,
>
Quote:

> > Yes, ADAM has been renamed into LDS.
> > I did understand that Quest gives us this feature.
> > So, I knew about the path variable to set.
> > The real trouble for me is how to get the search done.
> > Which command should I use.
> > If you give me a complete example of the search of a CN from the root,
> > it would be great.
>
Quote:

> > Thanks in advance, Thomas.
>
Quote:

> > On 7 juil, 21:31, RichS [MVP] <RichS...@xxxxxx>
> > wrote:
Quote:

> > > AD Lightweight Directory Services is the new name for ADAM in Windows2008.
>
Quote:
Quote:

> > > Short answer is yes you can
>
Quote:
Quote:

> > > Easiest way is to use the Quest cmdlets *- there examples in the documentation
>
Quote:
Quote:

> > > or use directorysearcher
>
Quote:
Quote:

> > > $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
>
Quote:
Quote:

> > > then create the searcher as normal
>
Quote:
Quote:

> > > --
> > > Richard Siddaway
> > > All scripts are supplied "as is" and with no warranty
> > > PowerShell MVP
> > > Blog:http://richardsiddaway.spaces.live.com/
> > > PowerShell User Group:http://www.get-psuguk.org.uk
>
Quote:
Quote:

> > > "Shay Levy [MVP]" wrote:
> > > > Hi H4mm3r,
>
Quote:
Quote:

> > > > Like ADAM?
>
Quote:
Quote:

> > > > ---
> > > > Shay Levy
> > > > Windows PowerShell MVP
> > > > blog:http://blogs.microsoft.co.il/blogs/ScriptFanatic
>
Quote:
Quote:

> > > > H> Hi all,
> > > > H>
> > > > H> I would like to know if powershell could do a query in a LDS instance
> > > > H> on my localhost ?
> > > > H> If yes, what are the procedure to do so ?
> > > > H> Thanks in advance, Thomas.
> > > > H>
My System SpecsSystem Spec
Old 07-09-2008   #9 (permalink)
H4mm3r


 
 

Re: LDS query via powershell

Hi all,

Thanks Richard. Based on your example, I was able to make it works :
$strtofind = "youpi"
$root = [ADSI] "LDAP://localhost:389/dc=XXX,dc=YYY"
$searcher = new-object
System.DirectoryServices.DirectorySearcher($root)
$searcher.Filter = "(cn=$strtofind)"
$result = $searcher.FindAll()
echo $result

Now, I'll try to update the record. Do you know a good place for all
the basic documentation of the PowerShell language and API ?

On 8 juil, 14:39, RichS [MVP] <RichS...@xxxxxx>
wrote:
Quote:

> The search is the same as an AD search
>
> $struser = "BOSCH Herbert"
>
> $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
> $search = [System.DirectoryServices.DirectorySearcher]$root
> $search.Filter = "(cn=$struser)"
> $result = $search.FindOne()
>
> if you want to work with the result *you will need to do
>
> $usr = $result.getdirectoryentry()
>
> You can find more on LDAP filters at
>
> http://msdn.microsoft.com/en-us/library/aa746475.aspx
>
> --
> Richard Siddaway
> All scripts are supplied "as is" and with no warranty
> PowerShell MVP
> Blog:http://richardsiddaway.spaces.live.com/
> PowerShell User Group:http://www.get-psuguk.org.uk
>
> "H4mm3r" wrote:
Quote:

> > Hi all,
>
Quote:

> > Yes, ADAM has been renamed into LDS.
> > I did understand that Quest gives us this feature.
> > So, I knew about the path variable to set.
> > The real trouble for me is how to get the search done.
> > Which command should I use.
> > If you give me a complete example of the search of a CN from the root,
> > it would be great.
>
Quote:

> > Thanks in advance, Thomas.
>
Quote:

> > On 7 juil, 21:31, RichS [MVP] <RichS...@xxxxxx>
> > wrote:
Quote:

> > > AD Lightweight Directory Services is the new name for ADAM in Windows2008.
>
Quote:
Quote:

> > > Short answer is yes you can
>
Quote:
Quote:

> > > Easiest way is to use the Quest cmdlets *- there examples in the documentation
>
Quote:
Quote:

> > > or use directorysearcher
>
Quote:
Quote:

> > > $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
>
Quote:
Quote:

> > > then create the searcher as normal
>
Quote:
Quote:

> > > --
> > > Richard Siddaway
> > > All scripts are supplied "as is" and with no warranty
> > > PowerShell MVP
> > > Blog:http://richardsiddaway.spaces.live.com/
> > > PowerShell User Group:http://www.get-psuguk.org.uk
>
Quote:
Quote:

> > > "Shay Levy [MVP]" wrote:
> > > > Hi H4mm3r,
>
Quote:
Quote:

> > > > Like ADAM?
>
Quote:
Quote:

> > > > ---
> > > > Shay Levy
> > > > Windows PowerShell MVP
> > > > blog:http://blogs.microsoft.co.il/blogs/ScriptFanatic
>
Quote:
Quote:

> > > > H> Hi all,
> > > > H>
> > > > H> I would like to know if powershell could do a query in a LDS instance
> > > > H> on my localhost ?
> > > > H> If yes, what are the procedure to do so ?
> > > > H> Thanks in advance, Thomas.
> > > > H>
My System SpecsSystem Spec
Old 07-09-2008   #10 (permalink)
H4mm3r


 
 

Re: LDS query via powershell

Hi all,

Thanks Richard. Based on your example, I was able to make it works :
$strtofind = "youpi"
$root = [ADSI] "LDAP://localhost:389/dc=XXX,dc=YYY"
$searcher = new-object
System.DirectoryServices.DirectorySearcher($root)
$searcher.Filter = "(cn=$strtofind)"
$result = $searcher.FindAll()
echo $result

Now, I'll try to update the record. Do you know a good place for all
the basic documentation of the PowerShell language and API ?

Once agin, thanks for your input, Thomas.

On 8 juil, 14:39, RichS [MVP] <RichS...@xxxxxx>
wrote:
Quote:

> The search is the same as an AD search
>
> $struser = "BOSCH Herbert"
>
> $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
> $search = [System.DirectoryServices.DirectorySearcher]$root
> $search.Filter = "(cn=$struser)"
> $result = $search.FindOne()
>
> if you want to work with the result *you will need to do
>
> $usr = $result.getdirectoryentry()
>
> You can find more on LDAP filters at
>
> http://msdn.microsoft.com/en-us/library/aa746475.aspx
>
> --
> Richard Siddaway
> All scripts are supplied "as is" and with no warranty
> PowerShell MVP
> Blog:http://richardsiddaway.spaces.live.com/
> PowerShell User Group:http://www.get-psuguk.org.uk
>
> "H4mm3r" wrote:
Quote:

> > Hi all,
>
Quote:

> > Yes, ADAM has been renamed into LDS.
> > I did understand that Quest gives us this feature.
> > So, I knew about the path variable to set.
> > The real trouble for me is how to get the search done.
> > Which command should I use.
> > If you give me a complete example of the search of a CN from the root,
> > it would be great.
>
Quote:

> > Thanks in advance, Thomas.
>
Quote:

> > On 7 juil, 21:31, RichS [MVP] <RichS...@xxxxxx>
> > wrote:
Quote:

> > > AD Lightweight Directory Services is the new name for ADAM in Windows2008.
>
Quote:
Quote:

> > > Short answer is yes you can
>
Quote:
Quote:

> > > Easiest way is to use the Quest cmdlets *- there examples in the documentation
>
Quote:
Quote:

> > > or use directorysearcher
>
Quote:
Quote:

> > > $root = [ADSI] "LDAP://localhost:389/dc=xyz,dc=com"
>
Quote:
Quote:

> > > then create the searcher as normal
>
Quote:
Quote:

> > > --
> > > Richard Siddaway
> > > All scripts are supplied "as is" and with no warranty
> > > PowerShell MVP
> > > Blog:http://richardsiddaway.spaces.live.com/
> > > PowerShell User Group:http://www.get-psuguk.org.uk
>
Quote:
Quote:

> > > "Shay Levy [MVP]" wrote:
> > > > Hi H4mm3r,
>
Quote:
Quote:

> > > > Like ADAM?
>
Quote:
Quote:

> > > > ---
> > > > Shay Levy
> > > > Windows PowerShell MVP
> > > > blog:http://blogs.microsoft.co.il/blogs/ScriptFanatic
>
Quote:
Quote:

> > > > H> Hi all,
> > > > H>
> > > > H> I would like to know if powershell could do a query in a LDS instance
> > > > H> on my localhost ?
> > > > H> If yes, what are the procedure to do so ?
> > > > H> Thanks in advance, Thomas.
> > > > H>
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Is there a way to query DNS from powershell? PowerShell
PerfMon PowerShell Query PowerShell
Running WMI Query in without Powershell or VBS PowerShell
Query NT4 Domain from Powershell PowerShell
Query for ms-ds-creatorsid from Powershell PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46