PowerTip: Add Computer to Security Group with PowerShell

Summary: Use Active Directory PoweShell cmdlets to add a computer to a security group.

Hey, Scripting Guy! Question How can I use Windows PowerShell to add a computer to a security group?

Hey, Scripting Guy! Answer Use the Add-ADGroupMember cmdlet, and remember to use the SAM account name on the computer:

To add a computer called “STATION01” to a security group called “RDPEnabled”:

ADD-ADGroupMember “RDPEnabled” –members “STATION01$”

Note  The SAM account name has a “$” added to its name.

Comments (7)

  1. Anonymous says:

    hallo?i need help?bro)

  2. Thanks
    I’m using this commandlet Inside a for loop

  3. samson says:

    I read an article about a facebook bug that received a lot of recognition. The bug was discovered by a Brazilian programmer and facebook payed him 33 thousand for the information. That is something that I would like to discover!

  4. Taryel says:

    Thanx it’s work

  5. Christopher Blodgett 2 says:

    So I have a more in depth question about add-adgroup. Let me first say this works, and if I go in and "view" AD I see it. Lets say you wanted to add validation to your script as any good coder would. When I try to do get-adgroup within 5 minutes or so
    I get invalid group, but I can’t seem to locate any caching that would be preventing it from returning right away. Thoughts?

  6. BASATI says:

    Nice Article. Whenever I have a doubt, I just refer this one back. Thanks very much

Skip to main content