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
Solved

Get Active Directory User with Specific Attribute

Posted on 2013-12-06
8
1,076 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

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.
In this article, I am going to show you how to simulate a multi-site Lab environment on a single Hyper-V host. I use this method successfully in my own lab to simulate three fully routed global AD Sites on a Windows 10 Hyper-V host.
This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
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…

829 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