SID-500

Home » PowerShell » PowerShell: Finding Active Directory Contacts

PowerShell: Finding Active Directory Contacts

Active Directory user objects can login to domain, contact objects cannot. Contact objects appear in GAL. Contacts are typically used to represent external users for the purpose of sending e-mails. How to find them in PowerShell?

Sometimes they are scattered across organizational units. To find all of them run a simple PowerShell One-Liner.

Get-ADObject -Filter 'objectClass -eq "contact"' -Properties CN | Format-List CN

Unbenannt.PNG

Use an additional filter to retrieve only the contact whose name is Peter including all properties.

Get-ADObject -Filter {(objectClass -eq "contact") -and (cn -like "*Peter*")} -Properties *

Unbenannt.PNG


3 Comments

  1. rolandehle says:

    If you use pipe followed by the where-object clause, all objects of type contact will be read and then the output is filtered.

    Better use this, because it is faster:
    Get-adobject -filter {(objectclass -eq ‘contact’) -and (cn -like ‘*Peter*’)}

    Regards,
    Roland

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

WHOIS

My name is Patrick Grünauer (pewa2303). I am from Austria. On sid-500 I write about Windows, Cisco and IT-Security in English and German. Have fun while reading!

Patrick Gruenauer
Follow SID-500 on WordPress.com