Solved

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

Posted on 2012-12-27
9
549 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
  • 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
 

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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 500 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Following basic email etiquette rules will help you write a professional email and achieve a good, lasting impression with your contacts.
In this video we show how to create a User 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 >> Mailb…
To show how to create a transport rule 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 Mail Flow >> Rules tab.:  To cr…

707 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now