Export Contacts with Email Addresses from a Mailbox or Group of Mailboxes
Hello,
I am currently on Exchange 2007. Is there a way for me to export all of the email addresses from a user's mailbox contacts?Jason
April 27th, 2012 4:24pm
The Outlook option will not be feasible as I have over 200+ mailboxes. I have been working with the Powershell code and I am running into problems. I do have a SAN certificate installed on my CAS boxes so I omitted lines 8-36. Here is my final code
and I am just trying to execute on one mailbox, 'jwilliams'.
Start-Transcript c:\Transcript.txt
$casserverName = "colaexcas02"
$userName = "***** "
$password = "*****"
$domain = "lawfirm.local"
$dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.0\Microsoft.Exchange.WebServices.dll"
[void][Reflection.Assembly]::LoadFile($dllpath)
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2007_SP3)
$windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
$sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
$aceuser = [ADSI]$sidbind
$uri=[system.URI] ("<a href="https://"https://%22/">https://"</a> + $casserverName + "/ews/exchange.asmx")
$service.Url = $uri
$service.Credentials = New-Object System.Net.NetworkCredential($username,$password,$domain)
new-item -path c:\reportfile.csv -type file -force
get-mailbox -Identity jwilliams | Select PrimarySmtpAddress | foreach{
$ContactsFolderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Contacts,$_)
$view = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000)
$findResults = $Service.FindItems($ContactsFolderid,$view)
if($findResults)
{
foreach($contact in $findResults)
{
if($contact.EmailAddresses[0].address -like "*@*")
{
$result = $_ + " , " + $contact.EmailAddresses[0].address
}
Add-content -path c:\reportfile.csv -value $result
}
}
}
Stop-Transcript
This is how I executed the command and Error Message below:
[PS] C:\program files\microsoft\exchange server\scripts>ExportContacts.ps1 -whatif
Unexpected token 'https://%22/">https://"</a>' in expression or statement.
At C:\Program Files\Microsoft\Exchange Server\Scripts\ExportContacts.ps1:16 cha
r:57
+ $uri=[system.URI] ("<a href="https://"https://%22/">https://"</a> <<<< + $casserverNa
me + "/ews/exchange.asmx")
+ CategoryInfo : ParserError: (https://":String">https://%22/">https://"</a>:String
) [], ParseException
+ FullyQualifiedErrorId : UnexpectedTokenJason
Free Windows Admin Tool Kit Click here and download it now
April 27th, 2012 4:41pm
Hello Evan,
I am still trying to figure out this Powershell command. I will begin to investigate your solution as well to see if it is a better fit.Jason
April 27th, 2012 5:35pm
You can do this with Exchange Web Service and C#, VB.Net, or PowerShell...
See http://smtpport25.wordpress.com/2010/10/11/ews-powershell-to-access-contacts-on-the-exchange-mailbox/ for a PowerShell
script
Karl
When you see answers and helpful posts, please click Vote As Helpful, Propose As Answer, and/or Mark As Answer
My Blog: http://unlockpowershell.wordpress.com
My Book:
Windows PowerShell 2.0 Bible
My E-mail: -join ("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})
Free Windows Admin Tool Kit Click here and download it now
April 27th, 2012 5:56pm
Hi Jason,
How about the issue, any updates?
Thanks,
Evan Liu
TechNet Subscriber Supportin forum
If you have any feedback on our support, please contacttngfb@microsoft.comEvan Liu
TechNet Community Support
April 27th, 2012 9:34pm
Outlook is a easy way if you don't have too many mailboxes need to export.
If you have any question about that Powershell command, you can ask in this forum:
Exchange Development forum
http://social.technet.microsoft.com/Forums/da-dk/exchangesvrdevelopment/threads
Thanks,
Evan Liu
TechNet Subscriber Supportin forum
If you have any feedback on our support, please contacttngfb@microsoft.comEvan Liu
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
April 27th, 2012 11:16pm
Hello Jason,
You also can use Outlook to export all the email addresses from user's mailbox contacts.
Here is a related document for you:
Export contacts
http://office.microsoft.com/en-us/outlook-help/export-contacts-HA101870639.aspx
Thanks,
Evan Liu
TechNet Subscriber Supportin forum
If you have any feedback on our support, please contact
tngfb@microsoft.com
Evan Liu
TechNet Community Support
April 28th, 2012 2:39am
Sorry, I am not familiar with the PowerShell commands.
I will ask somebody (who familiar with it ) to check this for you.
Thanks,
Evan Liu
TechNet Subscriber Supportin forum
If you have any feedback on our support, please contacttngfb@microsoft.comEvan Liu
TechNet Community Support
Free Windows Admin Tool Kit Click here and download it now
April 28th, 2012 5:44am