Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Have a script but getting errors. Bulk upload contact to GAL office 365 from csv

$
0
0

I have found this script looks great, when I run it in PowerShell It creates the contacts, enters in the Name fields ( Name-first-last-email) but when it goes to the Set Contact parameter there are issues.

I am extremely new to this, found PowerShell 2 days ago so I do not know if there is other information you will need, if there is please let me know.

 

Here is the Script:

 

Import-Csv .\ExternalContacts.csv | ForEach {
 $NewMailContactParams = @{
        Name = $_.Name
        ExternalEmailAddress = $_.ExternalEmailAddress
    }
 if(($_.Alias)) {$NewMailContactParams.Add("Alias",$_.Alias)}
 if(($_.DisplayName)) {$NewMailContactParams.Add("DisplayName",$_.DisplayName)}
 if(($_.FirstName)) {$NewMailContactParams.Add("FirstName",$_.FirstName)}
 if(($_.Initials)) {$NewMailContactParams.Add("Initials",$_.Initials)}
 if(($_.LastName)) {$NewMailContactParams.Add("LastName",$_.LastName)}

 New-MailContact @NewMailContactParams

 $SetContactParams = @{
  Identity = $_.Name
 }
 if(($_.StreetAddress)) {$SetContactParams.Add("StreetAddress",$_.StretAddress)}
 if(($_.City)) {$SetContactParams.Add("City",$_.City)}
 if(($_.StateOrProvince)) {$SetContactParams.Add("StateOrProvince",$_.StateOrProvince)}
 if(($_.PostalCode)) {$SetContactParams.Add("PostalCode",$_.PostalCode)}
 if(($_.CountryOrRegion)) {$SetContactParams.Add("CountryOrRegion",$_.CountryOrRegion)}
 if(($_.Phone)) {$SetContactParams.Add("Phone",$_.Phone)}
 if(($_.OtherTelephone)) {$SetContactParams.Add("OtherTelephone",$_.OtherTelephone)}
 if(($_.MobilePhone)) {$SetContactParams.Add("MobilePhone",$_.MobilePhone)}
 if(($_.HomePhone)) {$SetContactParams.Add("HomePhone",$_.HomePhone)}
 if(($_.OtherHomePhone)) {$SetContactParams.Add("OtherHomePhone",$_.OtherHomePhone)}
 if(($_.Fax)) {$SetContactParams.Add("Fax",$_.Fax)}
 if(($_.OtherFax)) {$SetContactParams.Add("OtherFax",$_.OtherFax)}
 if(($_.Company)) {$SetContactParams.Add("Company",$_.Company)}
 if(($_.Title)) {$SetContactParams.Add("Title",$_.Title)}
 if(($_.WebPage)) {$SetContactParams.Add("WebPage",$_.WebPage)}
 if(($_.Notes)) {$SetContactParams.Add("Notes",$_.Notes)}
 
 Set-Contact @SetContactParams

 $SetMailContactParams = @{
  Identity = $_.Name
 }
 if(($_.CustomAttribute1)) {$SetMailContactParams.Add("CustomAttribute1",$_.CustomAttribute1)}
 if(($_.CustomAttribute2)) {$SetMailContactParams.Add("CustomAttribute2",$_.CustomAttribute2)}

 Set-MailContact @SetMailContactParams
   
 $MailContact = Get-MailContact $_.Name
    if(($_.Email2)) {$MailContact.EmailAddresses.Add($_.Email2)}
    if(($_.Email3)) {$MailContact.EmailAddresses.Add($_.Email3)}

    if($MailContact.EmailAddresses.Count -gt 1) {
     Set-MailContact $_.Name -EmailAddresses @{Add=$MailContact.EmailAddresses}
    }
}

 

Here is where I found the script:

http://sysadminfixes.wordpress.com/2012/12/11/rollin-with-my-gal/

 

Here is the Error I get

Tim Xxxxxxx               1424                                           MailContact
WARNING: The command completed successfully but no settings of 'Xxx ' have been modified
Jeanet Xxxxxxx          1423                                           MailContact
The command completed successfully but no settings of 'Xxxxxxx ' have been modified
Mike Xxxxxxx            1422                                           MailContact
WARNING: The command completed successfully but no settings of 'Xxxxxxx 'have been
Paul Xxxxxxx             1421                                           MailContact
WARNING: The command completed successfully but no settings of 'Xxxxxxx ' have been
Stephen Xxxx             1420                                           MailContact

 

Any Ideas?

 

 

 

 

 

 

 

 

 

*Side Note

I was trying to accomplish this task a different way for the last day and a half and I started a topic before I found this place, Here is the link to that topic , maybe someone can help me there because I got pretty far with the last attempts just couldn't close the deal...sad day:

http://community.office365.com/en-us/forums/156/p/228735/709398.aspx#709398


Viewing all articles
Browse latest Browse all 6937

Trending Articles