Thursday, April 28, 2011

Search Active Directory for user properties

We are working on a project where we need to gather user telephone numbers from Active Directory in order to verify and normalize the telephone number filed.  This filed has to be formatted in a certain way and it also must be unique to a user, or the integration of Exchange and Cisco Unity Connection will not work.  My first thought was to use DSquery and DSget, but I decided to use the Get-ADuser Powershell cmdlet. 

In this case I just wanted First and Lastname and office telephone number.  So I used the following PS scripts 

From the Windows 2008 r2 AD Powershell Module:
Get-Aduser –Filter * -properties TelephoneNumber | FT Name,TelephoneNumber | Out-File C:\telnumberdump.txt

I like to dump results to TXT file, so I formatted the output  to deisplay Name and Telephone Number and then saved it to C: with Out-File. 


TechNet PS User Management

No comments:

Post a Comment