Solved

Get Active Directory User with Specific Attribute

Posted on 2013-12-06
8
1,002 Views
Last Modified: 2013-12-07
I need to get a report of active, meaning not disabled, user accounts and if they have a corresponding attribute called EmployeeID, I've been using the following powershell command, however it does not return a value for employeeID, which when I browse ADSIedit, it is listed as an attribute, some with values and some blank.  What am I missing here?

Get-ADUser -LdapFilter "(&(!useraccountcontrol:1.2.840.113556.1.4.803:=2))" | Select-Object Name,UserPrincipalName,employeeID | Sort-Object UserPrincipalName > C:\export.txt
0
Comment
Question by:fireguy1125
  • 4
  • 2
  • 2
8 Comments
 
LVL 57

Expert Comment

by:Mike Kline
Comment Utility
Try

Get-ADUser -Filter 'enabled -eq $true' -properties * |select-object name, userprincipalname, employeeid

Thanks

Mike
0
 
LVL 57

Expert Comment

by:Mike Kline
Comment Utility
Just tested in my lab to make sure  I only have one user that has employee id populated

ID
Thanks
Mike
0
 
LVL 1

Author Comment

by:fireguy1125
Comment Utility
Is there any way to exclude a particular OU from this report?  Specifically the following OU and child OUs beneith it:  COMPANY.COM\Service Accounts

The Service Accounts OU contains 4 OUs beneath it called: Admin, Service, Test, Other
0
 
LVL 57

Accepted Solution

by:
Mike Kline earned 500 total points
Comment Utility
Try this

Get-ADUser -Filter 'enabled -eq $true' -properties * |where-object {$_.DistinguishedName      -notlike "*OU=service accounts,DC=company,DC=com*"} | select-object name, userprincipalname, employeeid

Thans

Mike
0
Wish Marketing would stop bothering you?

Is your marketing department constantly asking for new email signature updates? Are they requesting a different design for every department? Do they need yet another banner added? Don’t let it get you down! There is an easy way to manage all of these requests...

 
LVL 3

Expert Comment

by:Detlef001
Comment Utility
0
 
LVL 57

Expert Comment

by:Mike Kline
Comment Utility
Those links really didn't make sense for the follow up question.

Thanks

Mike
0
 
LVL 3

Expert Comment

by:Detlef001
Comment Utility
I think Mcknife the link that i gave on the option

" Use the PowerShell AD Provider to Modify User Attributes " is the same that describe Get " Active Directory User with Specific Attribute ". If I'm wrong please explain where, so that it would be a learning for me itself.
0
 
LVL 1

Author Closing Comment

by:fireguy1125
Comment Utility
Exactly what I needed, thanks!
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Utilizing an array to gracefully append to a list of EmailAddresses
In this article, we will see the basic design consideration while designing a Multi-tenant web application in a simple manner. Though, many frameworks are available in the market to develop a multi - tenant application, but do they provide data, cod…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…

743 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

17 Experts available now in Live!

Get 1:1 Help Now