none
Import CVS via powershell Error - Member Already present RRS feed

  • Question

  • Hello,

    I've been trying to import some CVS file into exchange with the powershell management console.  I've created a script to import the CVS files below and to ignor the duplicate items:

    Import-Csv .\Contacts.csv|
        foreach-object {if (Get-MailContact -anr $_.displayname) {write-host $_.displayname 'is a duplicate entry'}     
        else {New-MailContact -Displayname $_.DisplayName -ExternalEmailAddress $_.EmailAddress -OrganizationalUnit “Contacts” -Alias $_.Alias}
        }

    However when I enter the command i just get the following message:

    Import-Csv : The member "Dale and Valley Homes" is already present.
    At C:\contactimport.ps1:1 char:11
    + Import-Csv <<<<  .\Contacts.csv|
        + CategoryInfo          : NotSpecified: (:) [Import-Csv], ExtendedTypeSystemException
        + FullyQualifiedErrorId : AlreadyPresentPSMemberInfoInternalCollectionAdd,Microsoft.PowerShell.Commands.ImportCsvC
       ommand

    I've been looking all over the forums and haven't found a solution to my problem. Any help would be appreciated.

    Thanks.

    Friday, October 10, 2014 2:17 PM

All replies