Solved

How to Query Active Directory for specific attribute

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
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…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

773 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