A Powershell Script To Copy The Contacts From An Exchange Public Folder To A Mailbox Contacts Folder

[ 61 ] Comments
Share

Here is a script to copy Exchange (2007,2010, and possibly 2013) Public Folder Contacts to an Exchange Mailbox Contacts folder.  It can be run in either Exchange Management Shell, or the plain PowerShell (since it loads the Exchange Admin snap-ins by itself).  Because it needs the snap-ins, it should be run on the Exchange Server itself, or maybe it will work if only the Management Console is installed – I don’t really know.  Note that the account you are logged in with will need application impersonation permission on the mailbox.  Unless it is your own mailbox, of course.

If you want to try it, copy the code into  a .ps1 file (e.g. CopyPFToContacts.ps1) and run it from the shell by navigating to the folder you put it in, and typing

.\CopyPFToContacts.ps1 <folderPath> <userSMTPAddress> <clearFolder>

where folderPath is the path of the Public Folder to Copy, userSMTPAddress is the email address of the user to receive the Contacts, and clearFolder is a flag to indicate whether to empty the folder first.  Here is an example:

.\CopyPFToContacts.ps1 \PublicContacts\WorldWide user@domain.com $True

If you want to copy the contacts to a folder that is not the default Contacts folder, you can supply the destination folder as the fourth positional parameter, like this

.\CopyPFToContacts.ps1 \Folder\SubFolder user@domain.com $True "\Contacts\Sub Folder"

or as a named parameter (if you are omitting the third parameter), like this

.\CopyPFToContacts.ps1 \Folder\SubFolder user@domain.com -destination "\Contacts\Sub Folder"

In either case, the destination folder is specified as a path relative to the mailbox root, not the default Contacts folder.  If you want the script to create the folder, you can supply the parameter -createFolder $True.  Remember that if you are supplying all parameters to the script, and in the correct order, you can omit the parameter names.

# CopyPFToContacts.ps1
# By Lee Derbyshire
# Parameter 0 = Public Folder Path
# Parameter 1 = Mailbox SMTP address
# Parameter 2 = Empty folder first?
# Parameter 3 = Destination folder if not default Contacts folder
# Parameter 4 = Create destination folder if absent?
# Usage examples:
# CopyPFToContacts.ps1 \Folder\SubFolder user@domain.com $False
# CopyPFToContacts.ps1 \Folder\SubFolder user@domain.com $True "\Contacts\Sub Folder"
# CopyPFToContacts.ps1 \Folder\SubFolder user@domain.com -destination "\Contacts\Sub Folder"

param([Parameter(Position=0,Mandatory=$True,HelpMessage="The path of the folder to copy")]
      [string]$folderPath,
      [Parameter(Position=1,Mandatory=$True,HelpMessage="Email Address of the target Mailbox")]
      [string]$mailbox,
      [Parameter(Position=2,Mandatory=$False,HelpMessage="Whether or not to empty the folder first")]
      [bool]$clearFolder,
      [Parameter(Position=3,Mandatory=$False,HelpMessage="The path of the destination folder")]
      [string]$destination,
      [Parameter(Position=4,Mandatory=$False,HelpMessage="Whether or not to create the destination folder")]
      [bool]$createFolder
)

# Add the snapin in case we're in the plain (i.e. non-Exchange Management) Shell

# Try the E2007 snapin first
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin -ErrorAction SilentlyContinue
# Then try the E2010 snapin
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 -ErrorAction SilentlyContinue
# This assumes you have v2.0 of the EWS Managed API
Add-Type -Path "C:\Program Files\Microsoft\Exchange\Web Services\2.0\Microsoft.Exchange.WebServices.dll"

# Supply the folder path, then try to locate it

$ews = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService("Exchange2007_SP1")
$ews.ImpersonatedUserId = New-Object Microsoft.Exchange.WebServices.Data.ImpersonatedUserId([Microsoft.Exchange.WebServices.Data.ConnectingIdType]::SmtpAddress, $mailbox)
$ews.AutodiscoverUrl($mailbox)
$rootFolderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::PublicFoldersRoot)
$folder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($ews, $rootFolderId)
$arrPath = $folderPath.Split("\")
for ($i = 1; $i -lt $arrPath.length; $i++)
{
  $folderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1)
  $searchFilter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName, $arrPath[$i])
  $findFolderResults = $ews.FindFolders($folder.Id, $searchFilter, $folderView)
  if ($findFolderResults.TotalCount -gt 0)
  {
    $folder = $findFolderResults.Folders[0]
  }
  else
  {
    "$folderPath Not Found"
    exit
  }
}

if ($destination)
{
  $mbRootFolderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::MsgFolderRoot)
  $mbFolder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($ews, $mbRootFolderId)
  $arrMbPath = $destination.Split("\")
  for ($i = 1; $i -lt $arrMbPath.length; $i++)
  {
    $folderName = $arrMbPath[$i]
    $mbFolderView = New-Object Microsoft.Exchange.WebServices.Data.FolderView(1)
    $mbSearchFilter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.FolderSchema]::DisplayName, $arrMbPath[$i])
    $mbFindFolderResults = $ews.FindFolders($mbFolder.Id, $mbSearchFilter, $mbFolderView)
    if ($mbFindFolderResults.TotalCount -gt 0)
    {
      $mbFolder = $mbFindFolderResults.Folders[0]
    }
    else
    {
      if (!$createFolder)
      {
        "$destination Not Found"
        exit
      }
      else
      {
        $newFolder = New-Object Microsoft.Exchange.WebServices.Data.Folder($ews)
        $newFolder.DisplayName = $folderName
        $newFolder.FolderClass = "IPF.Contact"
        $newFolder.Save($mbFolder.Id)
        $mbFolder = $newFolder
      }
    }
  }
  $contactsFolderId = $mbFolder.Id
}
else
{
  $contactsFolderId = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Contacts)
}

if ($clearFolder)
{
  # Delete the items in the folder
  # Note that E2007 doesn't have folder.Empty()
  # Could have used just folder.Empty() in >= E2010
  $itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000)
  do
  {
    $findItemResults = $ews.FindItems($contactsFolderId, $itemView)
    foreach ($item in $findItemResults.Items)
    {
      $item.Delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete)
    }
  }
  while ($findItemResults.MoreAvailable)
}

$itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(1000)
do
{
  $findItemResults = $ews.FindItems($folder.Id, $itemView)
  foreach ($item in $findItemResults.Items)
  {
    $item.DisplayName
    $item.Copy($contactsFolderId)
  }
}
while ($findItemResults.MoreAvailable)

61 Responses to A Powershell Script To Copy The Contacts From An Exchange Public Folder To A Mailbox Contacts Folder

  1. Andrew Gate says:

    Is it possible that it only updates existing contacts.
    can it check if it already exists and if so, update it ( delete it and re-add)
    we would like all of the managers to have a copy of each users contacts details so it sync to their phones. but not delete the whole destination folder, as they might have real personal data as well.

    • admin says:

      Hi Andrew. You’re not the first person to ask, and I don’t think you’ll be the last, but it turns out that updating existing contacts is impractical. Other people who have done similar scripts don’t try it, either. The problems are:

      1. Contacts deleted at the server end don’t get deleted at the client end.
      2. If you use a name search to do the match, you will miss people whose name changes as a result of marriage.
      3. There is no other way to reliably match the server contact to the mailbox contact.
      4. The processing load on the server is immense.

      So I really can’t recommend it, I’m afraid. To prevent deleting personal contacts, I’d suggest having all the server-copied ones in their own folder.

  2. Marin says:

    How can I put in parameter public folder? Where is located?

    I have tried, but without success… Is there some special folder location or what?

    Thank you for explanation…

    • admin says:

      Hello Marin, and thanks for your message. The folder path is supplied as a parameter when you call the script from the powershell command line. There is an example in the article:

      CopyPFToContacts.ps1 \Folder\SubFolder user@domain.com $False

      In this example, the path is \Folder\Subfolder , but you will obviously replace that with your own path.

      Please let me know if I did not explain it well enough, or if you need any other help with it.

  3. Tim says:

    Hi,

    sorry for my humble question, but is there a possibility to define the destination folder? lets say, I want to copy those contacts to a subfolder of the users contacts folder..

    Thanks in advance.
    Best,
    Tim

    • admin says:

      Hello Tim. Yes, the folderpath is specified as one of the parameters passed to the script. See if you can find the usage example in the comments at the beginning of the code.

  4. Mike B says:

    For this line in the script I get errors when I run it [Parameter(Position=2,Mandatory=$False,HelpMessage="$False")]
    [bool]$clearFolder

    This is the error that I get: ParameterAttributeArgumentNeedsToBeConstantOrScriptBlock

    • admin says:

      Hello Mike. I’ve tried the script again here, and it’s still working okay. Can you tell me what parameter values you are passing to it?

  5. Matthias Keller says:

    Hi,

    can i use this script with Office 365?

    Best regards

    Matthias

    • admin says:

      Hi Matthias. I’m afraid I’ve no idea if it will work in O365. I don’t have O365, so I can’t try it. Can’t do any harm to try, though.

  6. Mike B says:

    I put in the parameters here
    # CopyPFToContacts.ps1 \exchange\script user@domain.com $False

    I change the settings here
    param([Parameter(Position=0,Mandatory=$True,HelpMessage="\exchange\script ")]
    [string]$folderPath,
    [Parameter(Position=1,Mandatory=$True,HelpMessage="user@domain.com")]
    [string]$mailbox,
    [Parameter(Position=2,Mandatory=$False,HelpMessage="$False")]
    [bool]$clearFolder
    )

    Do I leave these as is or do I replace them

    • admin says:

      Hi Mike. You don’t put the parameters in the script. You add them to the command line when you type the name of the script into the powershell prompt. Like in the example

      .\CopyPFToContacts.ps1 \PublicContacts\WorldWide user@domain.com $True

      The script is left untouched, as it appears in the article.

  7. Mike B says:

    is this supported in exchange 2013 cu8

  8. Eric W says:

    Any way to only sync a certain category of contacts from the public folder?

    • admin says:

      It will certainly be possible, but I can’t test this at the moment, and it’s a bit of a guess. It will need a change near the end. Instead of

      $findItemResults = $ews.FindItems($folder.Id, $itemView)

      try

      $searchFilter = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+Contains([Microsoft.Exchange.WebServices.Data.ItemSchema]::Categories, “YourCategory”)
      $findItemResults = $ews.FindItems($folder.Id, $searchFilter, $itemView)

  9. Eric Jordan says:

    I see where you define the source, but how about a different destination than Contacts? ie, the Public Folder is Firm_Contacts and I want it to go into the user mailbox in Firm_Contacts…Not the default contacts folder…Thanks!

  10. Nick says:

    Hello,
    The works great! One issue I’m having, though… If I specify a custom destination, it seems that the script won’t actually create a subfolder if it doesn’t already exist in the Contacts for a user. For example, I want to copy contacts from the OrgContacts public folder to subfolder called OrgContacts in my user’s mailbox. If that subfolder doesn’t already exist in the user’s Contacts, the script does not run and I get an error saying “\Contacts\OrgContacts Not Found”.
    Should the script be creating that subfolder for me? Or do I need to find another way to create that subfolder for my users?

    Thanks!
    Nick

    • admin says:

      I’d sort of assumed that the folder would exist, and didn’t want to risk having the admin accidentally create a folder, or even a whole hierarchy, in the wrong place. I should be able to get it to create the folder, though. I’ll take another look at it.

    • admin says:

      Hello again Nick. I added some extra code, and an extra parameter so that you can tell it if you need to create the folder.

  11. Marin says:

    I am getting following error:

    Exception calling “Bind” with “2″ argument(s): “The account does not have permission to impersonate the requested
    user.”
    At C:\install\Copy_Contacts.ps1:36 char:1
    + $folder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($ews, $rootFolderId …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ServiceResponseException

    Exception calling “FindFolders” with “3″ argument(s): “Value cannot be null.
    Parameter name: parentFolderId”
    At C:\install\Copy_Contacts.ps1:42 char:3
    + $findFolderResults = $ews.FindFolders($folder.Id, $searchFilter, $folderView)
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : ArgumentNullException

    • admin says:

      This error message is saying that EWS doesn’t believe you have permission to access the mailbox. Are you using the script with your own mailbox, or with someone else’s?

  12. Nick says:

    Thanks so much! I hate to say I’m running into a bit of trouble with the new parameter, though. When I run the script like this:

    .\CopyPFToContacts.ps1 “All Public Folders\OrgContacts\Org Contact List” user@domain.com $True -destination \Contacts\OrgContacts $True

    … I get the following error:

    Exception calling “Copy” with “1″ argument(s): “Value cannot be null.
    Parameter name: destinationFolderId”
    At C:\Scripts\CopyPFToContacts.ps1:118 char:15

    Not sure if it’s something I’m doing wrong or what. Still works if the folder already exists, though!

  13. Nick says:

    I may have left off part of the error message in my previous reply:

    Exception calling “Copy” with “1″ argument(s): “Value cannot be null.
    Parameter name: destinationFolderId”
    At C:\Scripts\CopyPFToContacts.ps1:118 char:15
    + $item.Copy <<<< ($contactsFolderId)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

  14. Nick says:

    I think I found the issue. The $foldername variable is undeclared in the line:
    $newFolder.DisplayName = $folderName
    If I add a new line with:
    $foldername = OrgContacts
    … it creates the folder properly. There’s probably a way more elegant way to do that other than the way that I did it!

    • admin says:

      Hi Nick. Sorry for the confusion. I missed out a line when I copy/pasted my changes into the article. I missed out the line that now says

      $folderName = $arrMbPath[$i]

  15. Nick says:

    Thanks so much!

  16. Marin says:

    I am running this script directly on Exchange server, where I am logged in with domain admin account.

    I am using then this script for one other mailbox.

    How can I give permissions to this domain admin account for all mailboxes?

  17. Marin says:

    Now I have the perfect solution to distribute contact list to all mailboxes, and with that to their mobile phones.

    Is there a way to sync one of Exchange address list to this public folder automatically?

    I am using one address list in Exchange (created from AD) for distribution to all our company users. Until now, I have did it manually, but now I am using your script/s with Public folder.

  18. Marin says:

    Or, maybe we can bypass Public folder contacts, and copy contacts from specific Exchange Address List to Contacts from all mailboxes?
    Is there a way to adjusts/recreate the script?

    This would be awesome…

  19. Marin says:

    Oppps… I found your script for this :-)

  20. Kevin Pare says:

    Script works great! but when we run it as follows from a batch file:

    PowerShell.exe -noprofile -command c:\scripts\CopyPFToContacts.ps1 “\Customer Folders\Company\Company Contacts” me@me.ca 1 -destination “\Contacts\Company Contacts” 1

    We get this error:
    C:\scripts\CopyPFToContacts.ps1 : Cannot process argument transformation on par
    ameter ‘clearFolder’. Cannot convert value “System.String” to type “System.Bool
    ean”, parameters of this type only accept booleans or numbers, use $true, $fals
    e, 1 or 0 instead.
    + CategoryInfo : InvalidData: (:) [CopyPFToContacts.ps1], ParentC
    ontainsErrorRecordException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,CopyPFToCon
    tacts.ps1

    • admin says:

      Hi Kevin. I never tried to run it from a batch file, but instead of the 1′s, try using $True instead.

      PowerShell.exe -noprofile -command c:\scripts\CopyPFToContacts.ps1 “\Customer Folders\Company\Company Contacts” me@me.ca mailto:me@me.ca $True -destination “\Contacts\Company Contacts” $True

  21. Guillaume says:

    Sadly it appears all of the exchange commands are different, and therefore it didn’t work for us.

    I hope someone will one day take the time to translate it to Office365/Exchange Online, as this script would be very usefull.

    Regards

    • admin says:

      I only have on-premises to play with. As a developer, I don’t have much use for O365.

      You might try posting in one of the Exchange TechNet forums, and see if anyone can suggest a way to convert it.

  22. Cromm says:

    Nice Script works well except u have more than 1000 Contacts to copy or delte then u have to page through all contacts:

    if ($clearFolder) {
    $totalcount=0
    while(-not $NoMoreItems) {
    $Offset=0
    $PageSize=1000
    $Offset = 0
    $MoreItems =$true
    $ItemCount=0
    while ($MoreItems) {
    $itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView($PageSize,$Offset,[Microsoft.Exchange.WebServices.Data.OffsetBasePoint]::Beginning)
    $findItemResults = $ews.FindItems($contactsFolderId, $itemView)
    foreach ($item in $findItemResults.Items) {
    $ItemCount=$ItemCount+1
    $totalCount=$totalCount+1
    $totalCount
    $item.Delete([Microsoft.Exchange.WebServices.Data.DeleteMode]::HardDelete)
    }
    if ($findItemResults.MoreAvailable -eq $false) {
    $MoreItems = $false
    }
    if ($MoreItems) {
    $Offset += $pageSize
    }
    }
    If ($ItemCount -eq 0){
    $nomoreItems=$True
    }
    }
    }

    $Offset=0
    $PageSize=1000
    $Offset = 0
    $MoreItems =$true
    $ItemCount=0
    while ($MoreItems) {
    $itemView = New-Object Microsoft.Exchange.WebServices.Data.ItemView($PageSize,$Offset,[Microsoft.Exchange.WebServices.Data.OffsetBasePoint]::Beginning)
    $findItemResults = $ews.FindItems($folder.Id, $itemView)
    foreach ($item in $findItemResults.Items) {
    $ItemCount=$ItemCount+1
    $ItemCount
    $item.DisplayName
    $item.Copy($contactsFolderId)
    }
    if ($findItemResults.MoreAvailable -eq $false) {
    $MoreItems = $false
    }

    if ($MoreItems) {
    $Offset += $pageSize
    }
    }
    }

    • admin says:

      Thanks for that very useful feedback. I nearly always forget the situations where the numbers are very big. I’m only used to dealing with small samples.

  23. Cromm says:

    Feel free to use :)

  24. Miha says:

    HI
    I have a problem running this script. I ran it with domain administrator and I get an error:
    This are the parameters i used: \GTest\GMiha miha@domain.com $True “\Contacts\GMI” $False

    Exception calling “AutodiscoverUrl” with “1″ argument(s): “The Autodiscover service returned an error.”
    At C:\TEmp\SyncContacts.ps1:38 char:21
    + $ews.AutodiscoverUrl <<<< ($mailbox)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "Bind" with "2" argument(s): "The Url property on the ExchangeService object must be set."
    At C:\TEmp\SyncContacts.ps1:40 char:61
    + $folder = [Microsoft.Exchange.WebServices.Data.Folder]::Bind <<<< ($ews, $rootFolderId)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Exception calling "FindFolders" with "3" argument(s): "Value cannot be null.
    Parameter name: parentFolderId"
    At C:\TEmp\SyncContacts.ps1:46 char:40
    + $findFolderResults = $ews.FindFolders <<<< ($folder.Id, $searchFilter, $folderView)
    + CategoryInfo : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : DotNetMethodException

    Could you please help?

    BR
    Miha

    • admin says:

      I haven’t seen that before, but it looks like your EWS Autodiscover isn’t working. I think it just means that you will have to manually tell the EWS service what the EWS URL is, instead of letting it work it out (i.e. Autodiscover it) for itself.

      Try changing the line that says

      $ews.AutodiscoverUrl($mailbox)

      to

      $ews.Url = new Uri(“https://yourservername/EWS/Exchange.asmx”)

      But use your own CAS server name, of course :-)

  25. Dominique says:

    Hi
    This script is such a great held fo me. Can you tell me would it be possible to apply the copy to a group of mailboxes / users? Thanks

    • admin says:

      You could try it with a bit more powershell, I think. Open an EMS cmd window, and, to practise, type in

      import-module activedirectory
      $g = get-adgroupmember “Your Group Name”
      foreach($u in $g)
      >>{
      >>$e = get-aduser $u -properties mail | select-object mail
      >>$e
      >>}
      >>

      Press enter at the last >>, and hopefully, you’ll see the email addresses of “Your Group Name”. If so, then we’ll think of a way of passing them to the script within the {} loop.

  26. vassil says:

    Nice script.

    What needs to be modified in order to be able to copy Contacts within the same mailbox but into another Contacts folder?

    Thank you .

    Vassil

  27. VASSIL DIMOV says:

    What needs to be modified in order to be able to copy Contacts within the same mailbox but into another Contacts folder?

    • admin says:

      Okay, I’ll take a look.

    • admin says:

      Hi Vassil. If I understand your question correctly, there is already an input parameter to the script that will do this. Try the

      -destination \Foldername\Subfoldername

      parameter when running the script. If you are asking about something else altogether, please let me know.

  28. Tim J says:

    On Exchange 2013 getting the following output from the script. Any ideas? I’ve used several combinations of parameters and always this output.

    At C:\scripts\ContactSyncScripts\CopyPFToContacts.ps1:20 char:28
    + [string]$destination,
    + ~
    Missing expression after ‘,’.
    At C:\scripts\ContactSyncScripts\CopyPFToContacts.ps1:20 char:27
    + [string]$destination,
    + ~
    Missing ‘)’ in function parameter list.
    At C:\scripts\ContactSyncScripts\CopyPFToContacts.ps1:21 char:33
    + A A A A A  [Parameter(Position=4,Mandatory=$False,HelpMessage="Whether or not to ...
    + ~
    Missing argument in parameter list.
    At C:\scripts\ContactSyncScripts\CopyPFToContacts.ps1:23 char:1
    + )
    + ~
    Unexpected token ')' in expression or statement.
    + CategoryInfo : ParserError: (:) [], ParseException
    + FullyQualifiedErrorId : MissingExpressionAfterToken

  29. Tim J says:

    Nevermind…some extra artifacts got pasted into the script.

    • admin says:

      Well done on finding the cause of the problem! I’ve not heard of that happening before. I’ll have to try it out here, and see if I have the same problem.

  30. Tim J says:

    Having the same issue running it from a scheduled task. The Boolean parameters are being treated as strings no matter what syntax I use. I’ve seen posts about converting a string input to a Boolean within the script but I have no clue.

    • admin says:

      Can you let me know what you typed as the command into the scheduler? It’s probably a question of getting quotes in the right place.

    • admin says:

      Apparently, it’s a known issue when using the -File parameter in the scheduler. Instead of typing

      -clearFolder $True
      (or just $True in the correct position)

      It has to be replaced with

      {-clearFolder:True}
      (note there is no $ in this form)

  31. Thomas says:

    Great script. Thanks for your help. I had to tweak it a little bit to get it to work for my environment.

    On the line that says #This assumes you have v2.0 of the EWS Managed API — I had to change this to 2.2 or it wouldn’t work.

    I’m trying to expand this out to a list of emails from a csv import but I haven’t found how to get it to work yet. Please update if you find out how to get this to work Dominique/admin. Thank you.

    • admin says:

      I don’t have much interest in Exchange these days, so I’m not likely to find out how to do it. In fact, I keep switching off the blog, but then people keep asking me to turn it back on again :-)

      But I’m sure there are more articles out there explaining how to import contacts from a csv file. Try searching for import exchange contacts from csv




Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>