PowerShell

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

7 replies »

  1. 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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.