Error in Powershell Import-CSV into Address Book: property cannot be empty
Hello, I'm trying to use Powershell to import contacts in a CSV to my Exchange 2010 address book. After some research, I came up with the following cmdlet to run (after opening a session to exchange): Import-CSV C:\rmcusers.csv | ForEach-Object { New-MailContact -Name $_."DisplayName" -DisplayName $_."DisplayName (RMC)" -FirstName $_."FirstName" -LastName $_."LastName" -Alias $_."Alias" -OrganizationalUnit $_."OU" -ExternalEmailAddress $_."EmailAddress" } This is what the CSV file contains: DisplayName,FirstName,LastName,Alias,OU,EmailAddress Dusty Fluffinstuff,Dusty,Fluffinstuff,Dusty,Mail Contacts,dfluffinstuff@test.com The reason for the "DisplayName (RMC)" usage is so that the display name uses the DisplayName field from the CSV file and adds "(RMC)" to the end of it, as this file is being used to add external contacts. When I run this cmdlet, however, I get this error: Invoke-Command : Cannot bind parameter 'DisplayName' to the target. Exception setting "DisplayName": "The property cannot be empty." At C:\Users\administrator.RLMS\AppData\Roaming\Microsoft\Exchange\RemotePowerShell\rlms-exch.rushmore.local\rlms-exch.rushmore.local.psm1:26195 char:29 + $scriptCmd = { & <<<< $script:InvokeCommand ` + CategoryInfo : WriteError: (:) [New-MailContact], ParameterBindingException + FullyQualifiedErrorId : ParameterBindingFailed,Microsoft.Exchange.Management.RecipientTasks.NewMailContact I don't really understand the error because the DisplayName field in the CSV file definitely exists and is not empty, and the field definitely exists in a new contact. Am I doing something wrong? Is there a better way to approach this problem? Any help is greatly appreciated, and I can provide more information as necessary. Thanks!
March 23rd, 2011 9:41pm

Awesome, thank you so much! That fixed the original problem! I'll probably edit the CSV file to get my "(RMC)" at the end of the display name-- it is probably less of a headache than to try and find a way to append it to a name. Unless there's a simple way, in which case I'd pretty interested! Maybe I'll just look for another cmdlet that'll let me append something to it after it's added.. I don't know. That's less important now. Thanks again! Much appreciated.
Free Windows Admin Tool Kit Click here and download it now
March 24th, 2011 12:32am

Hi, You've probably sorted it by now, but it is somwthing i've been playing with recently. I've found that using this works for me. -DisplayName ( $_.DisplayName + " " + "(RMC)" ) You should find that you get your space inbetween the words too. But I've never used brackets in the display name, it should still work though. Hope it helps.
May 15th, 2011 1:28pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics