none
Add contacts to multiple users via powershell?

    Question

  • Here is the scenario.  

    I have a list of about 60 users that need 100 or so contacts added to their "Contacts" folder in outlook.

    Is there a way that I can "push" an excel or csv file of the contacts to their contacts folder?

    Its the same 100 contacts that need to go to all of these users.

    The reason they need to be added to their "Contacts" folder is because they need to be able to see these contacts on their blackberry(which is configured with BES on our environment).

    Any ideas? 

    Tuesday, July 19, 2011 6:44 PM

Answers

  • once you have a PST with the contacts in it, then you can import them without user intervention by using powershell. Something like the following:

    $Users = Import-Csv c:\users.csv
    
    Foreach ($User in $Users) {
    New-MailboxImportRequest -Mailbox $User.email -FilePath c:\contacts.pst -confirm:$false -Verbose
    }
    

    That would import the pst to all users listed in the csv.

     

    For the BES portion, only BES 5.0 has that option

    http://btsc.webapps.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB19111


    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com
    • Proposed as answer by NickCozby Tuesday, July 19, 2011 8:01 PM
    • Marked as answer by OldSchoola Wednesday, July 20, 2011 8:12 PM
    Tuesday, July 19, 2011 7:51 PM

All replies

  • The only way to do it through Powershell is to import them into a mailbox, then export the contacts from outlook to a PST, then import that PST to the 60 users that need it. Or with BES 5.0 you can put the contacts in a contact Public folder and then all the users can see them on their blackberries.
    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com
    Tuesday, July 19, 2011 6:53 PM
  • "then import that PST to the 60 users that need it." - this would require manual intervention of users importing the contacts correct? if thats the case then its not an option.  

    I was hoping for more of a backend approach to importing these contacts for them.

    If the contacts are on a public folder, how would the users on bes see them?

    Tuesday, July 19, 2011 7:38 PM
  • Have a look at this:

    http://gsexdev.blogspot.com/2010/04/flexible-exchange-contact-creation.html


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Tuesday, July 19, 2011 7:50 PM
  • once you have a PST with the contacts in it, then you can import them without user intervention by using powershell. Something like the following:

    $Users = Import-Csv c:\users.csv
    
    Foreach ($User in $Users) {
    New-MailboxImportRequest -Mailbox $User.email -FilePath c:\contacts.pst -confirm:$false -Verbose
    }
    

    That would import the pst to all users listed in the csv.

     

    For the BES portion, only BES 5.0 has that option

    http://btsc.webapps.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB19111


    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com
    • Proposed as answer by NickCozby Tuesday, July 19, 2011 8:01 PM
    • Marked as answer by OldSchoola Wednesday, July 20, 2011 8:12 PM
    Tuesday, July 19, 2011 7:51 PM
  • what fields do i need to have in the csv in order for the script to work?

     

    as far as the bes option, would they see these contacts on their blackberry like they would other contacts if they open the address book on the blackberry? or would they have to open the public folder somehow(different from just opening their address book)?

    • Edited by OldSchoola Tuesday, July 19, 2011 8:14 PM
    Tuesday, July 19, 2011 8:09 PM
  • make it look like this:

     

    email

    john@domain.com

    jill@domain.com

    bob@domain.com


    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com
    Tuesday, July 19, 2011 8:13 PM
  • so just the full emaill of hte user? not the user account?
    Tuesday, July 19, 2011 8:40 PM
  • The primary email address of the account will associate it to the account
    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com
    Tuesday, July 19, 2011 9:00 PM
  • I get this error when i run it.

    Cannot validate argument on parameter 'Mailbox'. The argument is null. Supply a non-null argument and try the command a

    gain.

        + CategoryInfo          : InvalidData: (:) [New-MailboxImportRequest], ParameterBindingValidationException

        + FullyQualifiedErrorId : ParameterArgumentValidationError,New-MailboxImportRequest

     

    Cannot validate argument on parameter 'Mailbox'. The argument is null. Supply a non-null argument and try the command a

    gain.

        + CategoryInfo          : InvalidData: (:) [New-MailboxImportRequest], ParameterBindingValidationException

        + FullyQualifiedErrorId : ParameterArgumentValidationError,New-MailboxImportRequest

    Wednesday, July 20, 2011 5:22 PM
  • Its not getting the users from the csv. Did you make the top row in the csv "email"? What happens when you run the first line in the script by itself?

    $Users = Import-Csv c:\users.csv

    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com
    Wednesday, July 20, 2011 5:49 PM
  • yup, that was the issue. thank you so much.

    1 more question, i tried doing the input multiple times, and each time it duplicates the same user in the contacts folder.  is there a way to add in only the differet contacts?

    Wednesday, July 20, 2011 7:58 PM
  • Just add a -ConflictResolutionOption KeepSourceItem to the New-MailboxImportRequest line and it should not duplicate.

    http://technet.microsoft.com/en-us/library/ff607310.aspx
    DJ Grijalva | MCITP: EMA 2007/2010 SPA 2010 | www.persistentcerebro.com
    Wednesday, July 20, 2011 9:14 PM
  • I see what the issue is.

    Teh users already have these contacts, in their my contacts folder.  i am just trying to update some of the existing contacts in their contacts. if i create a new pdf with jsut these updated contacts it creates duplicate. even with that option chosen. 

    i thi nk it has something to do that with the original contacts werent added by me.

    Thursday, July 21, 2011 2:37 PM
  • It seems that the command mentioned earlier - does not want to work with exchange online mailboxes.

    Can someone assist with modifying the script to import into exchange online mailboxes ?

    Is there an alternative to 

    New-MailboxImportRequest  ?
    Thursday, June 07, 2018 5:35 AM