locked
export contacts RRS feed

  • Question

  • I'm using follwing script to export all my user ;
    $contacts | export-csv contacts.csv -notype
    $contacts = get-recipient -resultsize unlimited | select name,alias,primaryaddress

    And on exchange 2010 i'm using to import follwing code;

    Import-CSV C:\Contacts.csv | ForEach-Object { New-MailContact -Name $_."Name" -DisplayName $_."Name" -Alias $_."Alias" -ExternalEmailAddress $_."PrimarySmtpAddress" }

    But i'm planning a migration from exc2007 to exc2010.i will use smtp namespace sharing scenario.But necessary of this scenario is ,there must be contacts for migrated users for mail flow.I used above script but on the target domain i need goup membership information of my contacts.

    Is it possible that exporting all my mailbox enabled users to csv with group membership information,and import into another exchange as contact with groups that they belong(all groups will be created before importing)

    Monday, March 15, 2010 10:20 AM

Answers

  • On Mon, 15 Mar 2010 10:20:40 +0000, biblo45 wrote:

    >
    >
    >I'm using follwing script to export all my user ;$contacts | export-csv contacts.csv -notype$contacts = get-recipient -resultsize unlimited | select name,alias,primaryaddressAnd on exchange 2010 i'm using to import follwing code;Import-CSV C:\Contacts.csv | ForEach-Object { New-MailContact -Name $_."Name" -DisplayName $_."Name" -Alias $_."Alias" -ExternalEmailAddress $_."PrimarySmtpAddress" }
    >
    >But i'm planning a migration from exc2007 to exc2010.i will use smtp namespace sharing scenario.But necessary of this scenario is ,there must be contacts for migrated users for mail flow.I used above script but on the target domain i need goup membership information of my contacts.Is it possible that exporting all my mailbox enabled users to csv with group membership information,and import into another exchange as contact with groups that they belong(all groups will be created before importing)

    PowerShell doesn't expose the "memberof" property. You can, however,
    use ADSI.

    $c = [ADSI]("LDAP://" + (get-recipient $_).distinguishedname)
    $m = $c.memberof

    You'll get the DN of each group. From there, if the groups are named
    identically in both forests, you can get the name of the group and add
    it to your CSV file.

    Dealing with multiple group memberships in a CSV file means that one
    of the properties is going to be a list. You'll have to deal with the
    list in the import script to add the object to each group.
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP

    --- Rich Matheisen MCSE+I, Exchange MVP
    • Proposed as answer by Alan.Gim Wednesday, March 17, 2010 6:20 AM
    • Marked as answer by Alan.Gim Monday, March 22, 2010 5:21 AM
    Monday, March 15, 2010 3:33 PM

All replies

  • On Mon, 15 Mar 2010 10:20:40 +0000, biblo45 wrote:

    >
    >
    >I'm using follwing script to export all my user ;$contacts | export-csv contacts.csv -notype$contacts = get-recipient -resultsize unlimited | select name,alias,primaryaddressAnd on exchange 2010 i'm using to import follwing code;Import-CSV C:\Contacts.csv | ForEach-Object { New-MailContact -Name $_."Name" -DisplayName $_."Name" -Alias $_."Alias" -ExternalEmailAddress $_."PrimarySmtpAddress" }
    >
    >But i'm planning a migration from exc2007 to exc2010.i will use smtp namespace sharing scenario.But necessary of this scenario is ,there must be contacts for migrated users for mail flow.I used above script but on the target domain i need goup membership information of my contacts.Is it possible that exporting all my mailbox enabled users to csv with group membership information,and import into another exchange as contact with groups that they belong(all groups will be created before importing)

    PowerShell doesn't expose the "memberof" property. You can, however,
    use ADSI.

    $c = [ADSI]("LDAP://" + (get-recipient $_).distinguishedname)
    $m = $c.memberof

    You'll get the DN of each group. From there, if the groups are named
    identically in both forests, you can get the name of the group and add
    it to your CSV file.

    Dealing with multiple group memberships in a CSV file means that one
    of the properties is going to be a list. You'll have to deal with the
    list in the import script to add the object to each group.
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP

    --- Rich Matheisen MCSE+I, Exchange MVP
    • Proposed as answer by Alan.Gim Wednesday, March 17, 2010 6:20 AM
    • Marked as answer by Alan.Gim Monday, March 22, 2010 5:21 AM
    Monday, March 15, 2010 3:33 PM
  • Please remember the [adsi]"LDAP part is uppercase sensitive


    James Luo
    TechNet Subscriber Support (http://technet.microsoft.com/en-us/subscriptions/ms788697.aspx)
    If you have any feedback on our support, please contact tngfb@microsoft.com
    Wednesday, March 17, 2010 6:20 AM