[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

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
?
639 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

New Tabletop Appliances Blow Competitors Away!

WatchGuard’s new T15, T35 and T55 tabletop UTMs provide the highest-performing security inspection in their class, allowing users at small offices, home offices and distributed enterprises to experience blazing-fast Internet speeds without sacrificing enterprise-grade security.

Question has a verified solution.

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

Stellar Exchange Toolkit: this 5 in 1 toolkit comes loaded with mega-software tool. Here’s an introduction to tools’ usage and advantages:
In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
Suggested Courses

872 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