Share via


add users from another domain to domain local groups

Question

Thursday, May 22, 2014 12:16 PM

Hello,

I'm looking for a way (with powershell) to add a user from domain A to a security (Domain Local) group of domain B. Manually this works. But does anyone has any idea how to do this with powershell?

Regards,

Lucvo

All replies (2)

Thursday, May 22, 2014 1:03 PM ✅Answered

You need to have the Active Directory Remote Server Administration Tools installed to be able to run this.  Once installed, from a powershell console that is running as an account that has privileges in your domain, run these commands:

Import-Module ActiveDirectory
$dn = Get-ADUser username -Server "different.domain.com"
Add-ADGroupMember -Identity YourDomainLocalGroup -Members $dn

Here's a good resource for installing the AD cmdlets:

http://blogs.msdn.com/b/rkramesh/archive/2012/01/17/how-to-add-active-directory-module-in-powershell-in-windows-7.aspx

I hope this post has helped!


Monday, May 26, 2014 1:37 AM ✅Answered

Hi Lucvo,

In addition, if this two domains in the same forest, and you can also run the cmdlet on the Domain Controller (DC), in this case, you can run the script posted by Rhys W Edwards directly without Remote Server Administration Tools:

Adding/removing members from another forest or domain to groups in Active Directory

If you have any questions, please feel free to let ma know.

If you have any feedback on our support, please click here.

Best Regards,

Anna

TechNet Community Support