?
Solved

Running LDAP query using Powershell

Posted on 2011-02-24
3
Medium Priority
?
1,419 Views
Last Modified: 2013-12-24
Hi

I asked the question below which was answered greatly...does anyone know how I can do this via Powershell in Windows 2008?

>>
Hi

We're running AD 2008 with 2008 Server member servers too. For some users we have a custom application that sets special AD attributes, these attributes are named

"customSync" - possible values YES, NO, SP1
"customEmail" - possible values PARTNER, SMTP1, SMTP2

What I'd like to do is run a query in AD to find users with some of these values, as below:

1. customSync=SP1
2. customEmail = SMTP1
3. customSync=YES *and* customEmail=SMTP2
4. customSync=YES *or& customEmail=SMTP2

I'd like to use ADUC to do this. I guess I can create a query within there, but after that I'm lost? All I can see is how to set queries for existing attributes (e.g. display name).

Could someone advise? I guess I need to run some sort of Custom Query but am not sure of which one and also the syntax to use for the four situations above.
>>

0
Comment
Question by:kam_uk
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 34968234
Just let know KenMcF about that. He will help you with PowerShell also :)
Paste link from this questioned to answered post and wait few hours ;)

Regards,
Krzysztof
0
 
LVL 27

Accepted Solution

by:
KenMcF earned 2000 total points
ID: 34969381
Hey iSiek :)

I would use the Quest AD cmdlets, it make it easier.

get-qaduser -searchroot "OU=USERSOU,DC=DOMAIN,DC=Local" -LDAPFILTER "(customSync=SP1)" | Select name, samaccountname | Export-csv c:\users.csv

get-qaduser -searchroot "OU=USERSOU,DC=DOMAIN,DC=Local" -LDAPFILTER "(&(customSync=YES)(customEmail=SMTP2))" | Select name, samaccountname | Export-csv c:\users.csv

get-qaduser -searchroot "OU=USERSOU,DC=DOMAIN,DC=Local" -LDAPFILTER "(|(customSync=YES)(customEmail=SMTP2))" | Select name, samaccountname | Export-csv c:\users.csv


http://www.quest.com/powershell/activeroles-server.aspx
0
 
LVL 39

Expert Comment

by:Krzysztof Pytko
ID: 35004218
Hi Ken :)

Quick, clear and easy ;)

Regards,
Krzysztof
0

Featured Post

Need protection from advanced malware attacks?

Look no further than WatchGuard's Total Security Suite, providing defense in depth against today's most headlining attacks like Petya 2.0 and WannaCry. Keep your organization out of the news with protection from known and unknown threats.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here's a look at newsworthy articles and community happenings during the last month.
In this blog post, we’ll look at how ClickHouse performs in a general analytical workload using the star schema benchmark test.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question