Solved

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

Posted on 2012-12-27
9
588 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
Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

 

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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Exchange 2007 6 24
controlling email signatures 3 29
nemesis decryptor - torproject.org 7 64
exchange 2007, calendar 3 21
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
Read this checklist to learn more about the 15 things you should never include in an email signature.
In this video we show how to create a mailbox database 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 Servers >> Data…
This video discusses moving either the default database or any database to a new volume.

730 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