Errors importing CSV file into Exchange 2007

rated by 0 users
This post has 2 Replies | 2 Followers

Not Ranked
Posts 2
Chum32 Posted: 08-29-2011 11:46 AM

Greetings:

 

I am trying to import a CSV file with all of my Outlook contacts into the Active Directory in Exchange 2007 as contacts, utilizing the following script:



_____________________________________________________________________________
Add-Content \\HLF-Server\Public\PSTs\debug.txt "::Starting Import: ";

$OU = 'Contacts' 
# Call CSV File & Create Mailboxes
Write-host "Creating Contacts..."


import-csv \\HLF-Server\public\PSTs\HLF-Contacts.csv |
foreach{
$entry = $_
$DN = $_.First +$_.Last;
New-MailContact $DN -DisplayName $DN -FirstName $_.First -LastName $_.Last -organizationalunit $OU -ExternalEmailAddress $_.email
Set-Contact $DN -Company $_.Company -Title $_.Title -Department $_.Department -Fax $_.Fax -MobilePhone $_.Mobile -Office $_.Location -Phone $_.Tel -PostalCode $_.Zip -PostOfficeBox $_.POBox -City $_.City -StreetAddress $_.StreetAdd -CountryorRegion $_.Country
Write-Host 'OU =' $OU
Write-host 'First Name =' $_.First
Write-Host 'Last Name =' $_.Last
write-host 'Display Name =' $DN
Write-Host 'Email Address =' $_.Email
Write-Host 'Company =' $_.Company
Write-Host 'Office =' $_.Location
Write-Host 'Title =' $_.Title
Write-Host 'Department =' $_.Department
Write-Host 'Telephone =' $_.Tel
Write-Host 'Fax =' $_.Fax
Write-Host 'Mobile No. =' $_.Mobile

Add-Content \\HLF-Server\Public\PSTs\debug.txt $err;

}

_____________________________________________________________________________

 

When I run that script, I receive the following error messages:

 


_____________________________________________________________________________
New-MailContact : Cannot bind argument to parameter 'ExternalEmailAddress' beca
use it is null.
At line:5 char:123
+ New-MailContact $DN -DisplayName $DN -FirstName $_.First -LastName $_.Last
-organizationalunit $OU -ExternalEmailAddress <<<< $_.email
+ CategoryInfo : InvalidData: (:) [New-MailContact], ParameterBin
dingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
icrosoft.Exchange.Management.RecipientTasks.NewMailContact

Set-Contact : Cannot bind argument to parameter 'Identity' because it is null.
At line:6 char:14
+ Set-Contact <<<< $DN -Company $_.Company -Title $_.Title -Department $_.De
partment -Fax $_.Fax -MobilePhone $_.Mobile -Office $_.Location -Phone $_.Tel -
PostalCode $_.Zip -PostOfficeBox $_.POBox -City $_.City -StreetAddress $_.Stree
tAdd -CountryorRegion $_.Country
+ CategoryInfo : InvalidData: (:) [Set-Contact], ParameterBinding
ValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,M
icrosoft.Exchange.Management.RecipientTasks.SetContact

_____________________________________________________________________________

 

 

Suggestions?

 

Thanks,

 

Ryan

Not Ranked
Posts 2

* bump *

Top 10 Contributor
Posts 658
Idera Employee

Check your incoming data in HLF-Contacts.csv. Looks like you have some Null data in $_.Email that New-MailContact cmdlet requires when using the -ExternalEmailAddress parameter for Exchange 2007.

http://technet.microsoft.com/en-us/library/bb124519(EXCHG.80).aspx

You are also missing Set-Contact -Identity <ContactIdParameter> which is a required parameter for Exchange 2007:

http://technet.microsoft.com/en-us/library/bb124535(EXCHG.80).aspx

Page 1 of 1 (3 items) | RSS
Copyright 2012 PowerShell.com. All rights reserved.