Solved

Running LDAP query using Powershell

Posted on 2011-02-24
3
1,412 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 500 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Recently, Microsoft released a best-practice guide for securing Active Directory. It's a whopping 300+ pages long. Those of us tasked with securing our company’s databases and systems would, ideally, have time to devote to learning the ins and outs…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles to another domain controller. Log onto the new domain controller with a user account t…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

724 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