Link to home
Start Free TrialLog in
Avatar of litog
litogFlag for United States of America

asked on

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

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
Avatar of Julian123
Julian123

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
Avatar of SubSun
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

Avatar of litog

ASKER

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
Avatar of litog

ASKER

$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
----------------------------------------------------------------------------------------------------
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?
Avatar of litog

ASKER

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

Avatar of litog

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial