• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 702
  • Last Modified:

search the telephone number of the contacts

Hi
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.

Thanks.
0
katacracks
Asked:
katacracks
  • 2
2 Solutions
 
kdagliCommented:
Below is the shell command:-

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

0
 
kdagliCommented:
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

0
 
GusGallowsCommented:
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

0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now