Solved

How to Query Active Directory for specific attribute

Posted on 2014-09-24
4
673 Views
Last Modified: 2014-10-22
Dear all,

How I can know which users don’t have picture imported in active directory? Is there a command or shell or anything I can use??

Thanks
0
Comment
Question by:Rhala
  • 2
4 Comments
 
LVL 16

Expert Comment

by:ThinkPaper
ID: 40342759
You can run a powershell query to check the value of thumbnailPhoto attribute for each user account.

Import-Module ActiveDirectory
 Get-ADUser -Filter * -SearchBase "OU=Staff,DC=nwtraders,DC=msft" -properties thumbnailPhoto | ? {!$_.thumbnailPhoto} | select Name

http://davehope.co.uk/Blog/find-accounts-without-a-thumbnail-photo/
http://social.technet.microsoft.com/Forums/windowsserver/en-US/f436cd38-8539-4883-903a-6f28c741e2c2/export-ad-users-thumbnailphoto-attributes-details-to-excel-spreadsheet?forum=winservergen
0
 
LVL 17

Expert Comment

by:Premkumar Yogeswaran
ID: 40345412
Hi,

Please find the option to query via DS Command:

To query users who doesn't have pictures in their User account.
dsquery * -filter "&(ObjectCategory=User)(!thumbnailPhoto=*)" - Limit 0 -attr DisplayName

Open in new window


To query users who have pictures in their User account.
dsquery * -filter "&(ObjectCategory=User)(thumbnailPhoto=*)" - Limit 0 -attr DisplayName

Open in new window



Regards,
Prem
0
 

Author Comment

by:Rhala
ID: 40348328
Dear ThinkPaper, it's seems the command provide the value which users have photo, what i need is a list of users which thy don't have photo.


Dear Premkumar Yogeswaran, i run the command and i get the below error:

Error
0
 
LVL 16

Accepted Solution

by:
ThinkPaper earned 500 total points
ID: 40350115
That command should be correct... I just ran the command and it worked on my environment


Users with photo:
----------------------------
Import-Module ActiveDirectory
 Get-ADUser -Filter * -SearchBase "OU=Staff,DC=nwtraders,DC=msft" -properties thumbnailPhoto | ? {$_.thumbnailPhoto} | select Name

Open in new window


Users without photo:
----------------------------
Import-Module ActiveDirectory
 Get-ADUser -Filter * -SearchBase "OU=Staff,DC=nwtraders,DC=msft" -properties thumbnailPhoto | ? {!$_.thumbnailPhoto} | select Name

Open in new window



Main difference is the "!" in front of $_.thumbnailPhoto which is like a "not"

For Premkumar's command, try removing the space between the "-" and "limit"
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Mac devices Integration with Active Directory 3 45
batch file problem 5 21
GPO help required 12 37
Applying GPO in GPMC 8 0
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
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…

911 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

24 Experts available now in Live!

Get 1:1 Help Now