Solved

Running LDAP query using Powershell

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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Last week, our Skyport webinar on “How to secure your Active Directory” (https://www.experts-exchange.com/videos/5810/Webinar-Is-Your-Active-Directory-as-Secure-as-You-Think.html?cid=Gene_Skyport) provided 218 attendees with a step-by-step guide for…
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

809 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