Solved

How to Query Active Directory for specific attribute

Posted on 2014-09-24
4
643 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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Join & Write a Comment

Introduction You may have a need to setup a group of users to allow local administrative access on workstations.  In a domain environment this can easily be achieved with Restricted Groups and Group Policies. This article will demonstrate how to…
Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
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 from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

707 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

18 Experts available now in Live!

Get 1:1 Help Now