?
Solved

How to Query Active Directory for specific attribute

Posted on 2014-09-24
4
Medium Priority
?
894 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
[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
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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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 the absence of a fully-fledged GPO Management product like AGPM, the script in this article will provide you with a simple way to watch the domain (or a select OU) for GPOs changes and automatically take backups when policies are added, removed o…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

764 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