none
Importing external contacts from a CSV file: Cannot bind argument to parameter 'Name' because it is an empty string. RRS feed

  • Question

  • Hi

    I trying to bulk import a CSV file called ExternalContacts.csv with just 4 fields:

    ExternalEmailAddress

     Name

     FirstName

     LastName

    And I use the command:

    Import-Csv .\ExternalContacts.csv|%{New-MailContact -Name $_.Name -DisplayName $_.Name -ExternalEmailAddress $_.ExternalEmailAddress -FirstName $_.FirstName -LastName $_.LastName}

    I then get the errors:

    Cannot bind argument to parameter 'Name' because it is an empty string.
        + CategoryInfo          : InvalidData: (:) [New-MailContact], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,New-MailContact
        + PSComputerName        : outlook.office365.com

    Cannot bind argument to parameter 'Name' because it is an empty string.
        + CategoryInfo          : InvalidData: (:) [New-MailContact], ParameterBindingValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,New-MailContact
        + PSComputerName        : outlook.office365.com

    What the heck am I doing wrong - it's a copy paste from: https://docs.microsoft.com/en-us/office365/securitycompliance/bulk-import-external-contacts

    Thursday, July 11, 2019 7:59 AM

Answers

  • I found the error!

    My first CSV file (when I opened it in Notepad) had semicolons as delimiters, once I searched and replaced them with commas, I was fine.

    It's such a PAIN to create external contacts via Powershell, I don't understand why MS didn't add an IMPORT button instead..

    Thursday, July 11, 2019 5:29 PM

All replies

  • The column names and the script sample seem fine, but the data must be populated for each row in the CSV, otherwise you will still get an error.
    Thursday, July 11, 2019 5:08 PM
  • I found the error!

    My first CSV file (when I opened it in Notepad) had semicolons as delimiters, once I searched and replaced them with commas, I was fine.

    It's such a PAIN to create external contacts via Powershell, I don't understand why MS didn't add an IMPORT button instead..

    Thursday, July 11, 2019 5:29 PM
  • I found the error!

    My first CSV file (when I opened it in Notepad) had semicolons as delimiters, once I searched and replaced them with commas, I was fine.

    It's such a PAIN to create external contacts via Powershell, I don't understand why MS didn't add an IMPORT button instead..

    It is a good idea, hope this feature would be added to the management GUI someday.

    Anyway, happy to know issue got resolved.

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Friday, July 12, 2019 9:02 AM
    Moderator
  • Thanks Manu. Trimming the CSV file for blank spaces was a pain. Once data was uploaded, updating contact data with powershell was easy.
    Friday, July 12, 2019 9:17 AM
  • Thanks Manu. Trimming the CSV file for blank spaces was a pain. Once data was uploaded, updating contact data with powershell was easy.

    I know that, but EMS only recognize the CSV file in a fixed format, and semicolons as delimiters is not included.

    I think issue here is more about the Excel, not Exchange server.

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, July 15, 2019 6:56 AM
    Moderator
  • Hi Manu

    I agree. At first I thought it was a powershell issue. I'm sorry.

    Monday, July 15, 2019 7:10 AM
  • Hi Manu

    I agree. At first I thought it was a powershell issue. I'm sorry.

    Never mind. You may ask in the Microsoft Office  >  Excel IT Pro Discussions forum and see if there is a solution.

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Click here to learn more. Visit the dedicated forum to share, explore and talk to experts about Microsoft Teams.

    Monday, July 15, 2019 7:20 AM
    Moderator
  • Oh I did find the solution as stated on my reply from 12th July (semi colons vs. commas). I consider this ticket as completed.
    Monday, July 15, 2019 7:41 AM
  • Oh I did find the solution as stated on my reply from 12th July (semi colons vs. commas). I consider this ticket as completed.

    OK, it is fine.

    Regards,

    Manu Meng


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Wednesday, July 17, 2019 8:56 AM
    Moderator