PowerShell for Windows Admins

Jan 26 2015   11:08AM GMT

Filtering on if an AD property exists

Richard Siddaway Richard Siddaway Profile: Richard Siddaway

Tags:
Active Directory
Powershell

There are times when you want to filter the results based on whether a user has an AD property set.  You could do this:

Get-ADUser -Filter * -Properties Title | Where Title  | select Name, Title

However, that involves pulling back all of the users and then filtering. Not very efficient especially across the network in a big domain.

A better solution would be to use an LDAP filter

Get-ADUser -LDAPFilter “(Title=*)” -Properties Title  | select Name, Title

Get-ADUser does the checking to see if the user has a title set so only those objects with that property are retrieved. If you want to see the value of the property you need to include it by using the –Properties parameter.

 Comment on this Post

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when other members comment.

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

Share this item with your network: