Export users phone-number to .csv-file

by PatricF at 2012-09-12 00:55:42

Hi,

I have a simple script that exports all the users on a Exchange server to a .csv file with their name and email-address. It looks something like this:


Remove-Item C:\Scripts\addressbook\organization\organization.csv
New-Item -ItemType file -Path C:\Scripts\addressbook\organization -Name organization.csv

Get-Mailbox | where {$_.name -notLike "DiscoverySearchMailbox*"} | Select DisplayName,PrimarySmtpAddress | Export-Csv -encoding "unicode" C:\Scripts\addressbook\organization\organization.csv



Then I use that .csv-file to import that information as external contacts on another server. Now to the problem. I need to export their phone-numbers as well, both work phone and mobile phone numbers.
How do I do this?
by PatricF at 2012-09-12 04:07:12
I was able to see the phone numbers with "Get-User"
by Martin9700 at 2012-09-12 06:18:19
Since Exchange uses Active Directory you should be able to do something like:

Get-ADUser -Filter * -property EmailAddress,MobilePhone,telephoneNumber | Select Name,EmailAddress,MobilePhone,telephoneNumber | Export-CSV C]