Solved

Running LDAP query using Powershell

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
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 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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now