Solved

Get Active Directory User with Specific Attribute

Posted on 2013-12-06
8
1,055 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
ID: 39701781
Try

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

Thanks

Mike
0
 
LVL 57

Expert Comment

by:Mike Kline
ID: 39701795
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
ID: 39702077
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
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.

 
LVL 57

Accepted Solution

by:
Mike Kline earned 500 total points
ID: 39702128
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
 
LVL 3

Expert Comment

by:Detlef001
ID: 39702189
0
 
LVL 57

Expert Comment

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

Thanks

Mike
0
 
LVL 3

Expert Comment

by:Detlef001
ID: 39702200
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
ID: 39703162
Exactly what I needed, thanks!
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
The following article is intended as a guide to using PowerShell as a more versatile and reliable form of application detection in SCCM.
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…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…

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