search the telephone number of the contacts

Posted on 2009-04-25
Last Modified: 2012-05-06
I'm need a script that will search the telephone numbers of the contacts existing in the private and/or public users folders of an Exchange 2007 within Active Directory.

WSH/VBscript is ok but Windows Powershell would be cool.

Question by:katacracks
    LVL 4

    Expert Comment

    Below is the shell command:-

    Get-Contact | where {$_.HomePhone -ne "$null" -or $_.MobilePhone -ne "$null" -or $_.Phone -ne "$null"} | select Name, HomePhone, Phone, MobilePhone

    LVL 4

    Accepted Solution

    If you are looking for a script that will search the contact based on the telephone number entered by you, let me know. I'll have to write one for you then.
    However, the above command should resolve your purpose if you take the output in csv file and open it in excel. Search for the said number is excel and look for corresponding contact :-)

    Get-Contact | where {$_.HomePhone -ne "$null" -or $_.MobilePhone -ne "$null" -or $_.Phone -ne "$null"} | select Name, HomePhone, Phone, MobilePhone, RecipientType | Export-csv c:\Contacts.csv

    LVL 12

    Assisted Solution

    Depending on how many contacts you have, a filter might be faster than a where statement.
    If you're looking for specific phone numbers, you could do something like this:
    #Prompt for and capture the phone number in question
    $Phone = Read-Host "What Phone number are you looking for?"
    #Search AD for the phone number
    Get-Contact -filter "phone -eq $phone -or MobilePhone -eq $phone -or HomePhone -eq $phone"

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Set OWA language and time zone in Exchange for individuals, all users or per database.
    Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
    In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
    The video tutorial explains the basics of the Exchange server Database Availability groups. The components of this video include: 1. Automatic Failover 2. Failover Clustering 3. Active Manager

    759 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

    10 Experts available now in Live!

    Get 1:1 Help Now