Solved

Get Active Directory User with Specific Attribute

Posted on 2013-12-06
8
1,027 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
 
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
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 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ADFS Redirection 4 32
Cloud to Hybrid 4 22
Help Decipher Powershell Script 5 14
Need to jump to previous line in  powershell 5 8
This article will help you understand what HashTables are and how to use them in PowerShell.
A safe way to clean winsxs folder from your windows server 2008 R2 editions
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…
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…

895 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

11 Experts available now in Live!

Get 1:1 Help Now