Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

EWS Exchange 2010 sp3 - script to export IPM.contacts from known public folder.

$
0
0

Hello,

We are using a powershell script on our EX2K10_SP3 server to export all contacts stored in all user mailboxes to a csv file. The script was found in several snippets through searching the internet as I am not a coder :-(Belwo is the relevant part of this script:

## Set the URL of the CAS (Client Access Server) to use two options are availbe to use Autodiscover to find the CAS URL or Hardcode the CAS to use    
$uri=[system.URI] "http://ex2k10_SP3/ews/exchange.asmx"    
$service.Url = $uri     

$outputfile = "E:\E2K10_SCRIPT\output\Kontakte_MBX_sample.csv"

#Header rows 
#'"Firma";"Vorname";"Nachname";"Strasse";"PLZ";"Stadt";"Land";' | Out-File -Encoding default -FilePath $outputfile -append

#traverse mailbox and pull out All Contacts
function getcontacts ([string]$MailboxName)
{
 $ContactsFolderid  = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Contacts,$MailboxName) 
 $view = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000,0) 
 $findResults = $Service.FindItems($ContactsFolderid,$view)

foreach($item in $findResults)
 {
$contactdata = ($item.PhysicalAddresses[0].Street) -replace "`r|`n"," ""$($item.CompanyName);$($item.GivenName);$($item.Surname);$contactdata;$($item.PhysicalAddresses[0].PostalCode);$($item.PhysicalAddresses[0].City);$($item.PhysicalAddresses[0].CountryOrRegion);" | Out-File -Encoding default -FilePath $outputfile -Append }
 }
#Pulls names from a csv file that you provide

foreach
($MailboxName in Get-Content "E:\E2K10_SCRIPT\Aliases.txt")
 { 
 getcontacts -MailboxName ($MailboxName)
 }

I am not a coder but I understand very limited the content of this script. Now I must do this against one known public Folder like \Contacts supplier . First of all I have now idea how to run this script against the public folder?

Any help and advise is appreciated. (The script should run once a week against one public folder, but it is not a WellKnownFolderName, so how access the folder?)

Regards,

Andreas



Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>