Link to home
Start Free TrialLog in
Avatar of Anthony K O365
Anthony K O365Flag for United States of America

asked on

Add users from one Domain to Security Group in different Domain

I have a csv file of users from Domain B and would like to add them to a SG in Domain A. Please share the PowerShell command that would accomplish this.

thank you
SOLUTION
Avatar of RTFM
RTFM
Flag of Germany 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
Avatar of Anthony K O365

ASKER

Yes, but I get 'cannot find object' b/c the csv file contain users from Domain B, but the SG is in Domain A.
SOLUTION
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
Here is my script:   My csv has column of SamAccountName

Import-module ActiveDirectory  

$Users = IpCSV "C:\Users2.csv"

$Group = [ADSI]"LDAP://[ADSI]"LDAP://cn=Test Group,ou=West,dc=MyDomain,dc=com"


$Users | %{Add-ADPrincipalGroupMembership -identity $_.samAccountName -server myDomain.com -MemberOf $Group

}  

I still error 'can't find object
This will probably work, I just need to know how to use the csv file of users from DomainBBB

$DomainBBBUser = Get-ADUser Test1 -Server $DomainBBB
Add-ADGroupMember Administrators -Members $DomainBBBUser

$DomainAAAGroup = Get-ADGroup Administrators
Add-ADPrincipalGroupMembership -Server $DomainBBB Test1 -MemberOf $DomanAAAGroup
ASKER CERTIFIED SOLUTION
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
Richard,

This in fact was done. Thank you!
closing