Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Copy members from one D.L. in one domain to another D.L. in another domain

Posted on 2012-12-27
9
Medium Priority
?
630 Views
Last Modified: 2013-12-04
Hello,

I have a CSV file with a list of distribution groups from both the new domain and the old domain. They are mapped. The CSV file contains two columns (Source, Target). I'd like to copy the members from the source domain to the target domain. The members already have the proxy addresses from the source domain so it should be possible to match a user as well based on one of the proxy addresses. Has anyone done this and/or does anyone have a sample script to get me started? I'd like to do this in Powershell.

Thanks
0
Comment
Question by:litog
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
9 Comments
 
LVL 12

Expert Comment

by:Julian123
ID: 38725970
You can do this using CSVIDE (that's how I typically do it). Here's an example on how to do it: http://exchangeis.com/blogs/exchangeis/archive/2005/07/14/35.aspx
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38726617
If you have a list in following format then try this PS script..

Sample CSV..
DGName,Proxy
TestDG,test@test.com
TestDG,test1@test.com
TestDG,test2@test.com
TestDG,test3@test.com
TestDG1,test@test.com
TestDG1,test3@test.com
TestDG1,test4@test.com

Open in new window


Import-CSV FileName.csv | ForEach {
$user = Get-Mailbox $_.Proxy
Add-DistributionGroupMember -Identity $_.DGName -Member $user.Name}

Open in new window

0
 

Author Comment

by:litog
ID: 38727493
Thanks for both of your responses. I may have not been clear in my question.

I have a mapped file with the old name (Group1) and new name (Group345). The mapped file contains two columns. Source, Target.

From this I want to look at the Source domain, find the members proxy address and find the matching proxy address on the target domain, and add those users to the D.L.

There issue here is that both the D.L., and the Users have been renamed in the new domain, so looking up the members by proxy address instead of the DN should make finding a matching user easier.

I hope I'm explaining myself correctly.

Thanks
0
NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

 

Author Comment

by:litog
ID: 38728294
$users = get-distributiongroupmember 'GlobalHSM' -domaincontroller w2342o.xthy.com -Credential $username | Select-Object primarysmtpaddress

foreach ($user in $users)

{

Add-DistributionGroupMember -Identity '&$HYMT_GlobalHSM' -Member $users -DomainController chicago.mglobal.com

}

I have the above powershell code so far, with just a single DL, but am receiving the following error;

---------------------------------------------------------------------------------------
Cannot process argument transformation on parameter 'Member'. Cannot convert the "System.Collections.ArrayList" value of type "System.Collections.Arr
ayList" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGroupIdParameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParam
eter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember

Cannot process argument transformation on parameter 'Member'. Cannot convert the "System.Collections.ArrayList" value of type "System.Collections.Arr
ayList" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGroupIdParameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParam
eter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember

Cannot process argument transformation on parameter 'Member'. Cannot convert the "System.Collections.ArrayList" value of type "System.Collections.Arr
ayList" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGroupIdParameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParam
eter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember

Cannot process argument transformation on parameter 'Member'. Cannot convert the "System.Collections.ArrayList" value of type "System.Collections.Arr
ayList" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGroupIdParameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParam
eter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember

Cannot process argument transformation on parameter 'Member'. Cannot convert the "System.Collections.ArrayList" value of type "System.Collections.Arr
ayList" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGroupIdParameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParam
eter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember
----------------------------------------------------------------------------------------------------
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38728321
Change the variable inside the foreach to  $user
$users = get-distributiongroupmember 'GlobalHSM' -domaincontroller w2342o.xthy.com -Credential $username | Select-Object primarysmtpaddress
foreach ($user in $users) {
Add-DistributionGroupMember -Identity '&$HYMT_GlobalHSM' -Member $user -DomainController chicago.mglobal.com
}

Open in new window


is this domains from same forest?
0
 

Author Comment

by:litog
ID: 38728350
Thanks! That got me a little further with a different error.


Cannot process argument transformation on parameter 'Member'. Cannot convert the "@{PrimarySmtpAddress=john.smith@xthy.com}" value of type "De
serialized.Selected.Microsoft.Exchange.Data.Directory.Management.ReducedRecipient" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUse
rGroupIdParameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember

Cannot process argument transformation on parameter 'Member'. Cannot convert the "@{PrimarySmtpAddress=conyesewe@xthy.com}" value of type "Deserializ
ed.Selected.Microsoft.Exchange.Data.Directory.Management.ReducedRecipient" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGroupId
Parameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember

Cannot process argument transformation on parameter 'Member'. Cannot convert the "@{PrimarySmtpAddress=mary.robins@xthy.com}" value of type "Dese
rialized.Selected.Microsoft.Exchange.Data.Directory.Management.ReducedRecipient" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserG
roupIdParameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember

Cannot process argument transformation on parameter 'Member'. Cannot convert the "@{PrimarySmtpAddress=joe.williams@xthy.com}" value of type "Deser
ialized.Selected.Microsoft.Exchange.Data.Directory.Management.ReducedRecipient" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGr
oupIdParameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember

Cannot process argument transformation on parameter 'Member'. Cannot convert the "@{PrimarySmtpAddress=wells.zuniga@xthy.com}" value of type "Deseria
lized.Selected.Microsoft.Exchange.Data.Directory.Management.ReducedRecipient" to type "Microsoft.Exchange.Configuration.Tasks.RecipientWithAdUserGrou
pIdParameter`1[Microsoft.Exchange.Configuration.Tasks.RecipientIdParameter]".
    + CategoryInfo          : InvalidData: (:) [Add-DistributionGroupMember], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Add-DistributionGroupMember
0
 
LVL 40

Expert Comment

by:Subsun
ID: 38728368
Try..
$users = get-distributiongroupmember 'GlobalHSM' -domaincontroller w2342o.xthy.com -Credential $username | Select-Object primarysmtpaddress
foreach ($user in $users) {
Add-DistributionGroupMember -Identity '&$HYMT_GlobalHSM' -Member $user.PrimarySmtpAddress.tostring() -DomainController chicago.mglobal.com
}

Open in new window

Or
$users = get-distributiongroupmember 'GlobalHSM' -domaincontroller w2342o.xthy.com -Credential $username | Select-Object primarysmtpaddress
foreach ($user in $users) {
Add-DistributionGroupMember -Identity '&$HYMT_GlobalHSM' -Member (Get-mailbox $user.PrimarySmtpAddress.tostring()).Name -DomainController chicago.mglobal.com
}

Open in new window

0
 

Author Comment

by:litog
ID: 38737061
That worked. Thanks! Now for the final part, is there a way to have the identity of the DL on a CSV file and use that instead of manually entering a DL name?

Thanks
0
 
LVL 40

Accepted Solution

by:
Subsun earned 2000 total points
ID: 38737475
Try this..
$username = Get-Credential
Import-Csv Test.csv | % {
$users = get-distributiongroupmember $_.Source -domaincontroller w2342o.xthy.com -Credential $username | Select-Object primarysmtpaddress
foreach ($user in $users) {
Add-DistributionGroupMember -Identity $_.Dest -Member $user.PrimarySmtpAddress.tostring() -DomainController chicago.mglobal.com
 }
}

Open in new window

CSV Format
Source, Dest
GlobalHSM,&$HYMT_GlobalHSM

Open in new window

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A walk-through example of how to obtain and apply new DID phone numbers to your cloud PBX enabled users that are configured in Office 365. Whether you have 1, 10 or 100+ users in your tenant, it's quite easy to get them phone-enabled and making/rece…
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
In this video we show how to create a Shared Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Sha…
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question