«

»

Aug 13

Add ADGroupMember

If you want to add a lot of computers to a AD Group it is simple if you have a text file and the name of the AD Group.

One thing I have noticed in my environment are that I can´t use just computer name, I need to use SamAccountName. That’s why I added a dollar sign in the end of $computer.

The textfile needs to look like this:
Computer1
Computer2
Computer3

Here is one way to do it.

#######################

$ADGroup = “Groupname”

$computers = get-content ‘c:\temp\listofcomputers.txt’

foreach ($computer in $computers)

{

Add-ADGroupMember -Identity $ADGroup -Members $computer$

}

#############################

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>