Solved

How to make new computers a member of a specific AD computer group automatically...by GPO maybe?

Posted on 2006-10-31
4
195 Views
Last Modified: 2010-03-18
Hi,
I would like to make any new computer accounts added to a specific organizational unit a member of a specific AD computer group.  For example...if my technicians join a new computer to the domain, and then move the computer account to a particular departmental OU, I would like the computer account to be automatically enterred into the appropriate AD computer group.  I had thought that there would probably be a setting in group policy that would do this for me but can't seem to find one off hand.  Any thoughts on how to do this?  
Thank you in advance for your help.

Tidbits about the network:  workstations are W2k Pro and WinXP Pro...AD is server 2003

0
Comment
Question by:AFAIT
  • 2
4 Comments
 
LVL 9

Expert Comment

by:SamuraiCrow
Comment Utility
You can do this with the netdom command.  The basic syntax looks like:

NETDOM JOIN <computer>/Domain:<domain> [/OU:<ou path>] [/UserD:<user>]

You could add this to a small batch file and have it prompt for passwords when it kicks off.  Read the following link for more details:
http://support.microsoft.com/kb/266651

Let me know if you would like assistance with the syntax
Crow

0
 
LVL 38

Accepted Solution

by:
Shift-3 earned 500 total points
Comment Utility
You could set up a scheduled task to periodically run the vbscript below.

Save the text below the line in a file with a .vbs extension.  Customize the strComputerOU variable with the Distinguished Name of the OU the computers are in.  Customize the strTargetGroup variable with the Distinguished Name of the group you want to add the computers to.

I borrowed the code from these Microsoft articles:
http://www.microsoft.com/technet/scriptcenter/resources/qanda/sept04/hey0902.mspx
http://www.microsoft.com/technet/scriptcenter/resources/qanda/jan06/hey0123.mspx

____________________

On Error Resume Next

'Distinguished Name of the OU the computers are in
strComputerOU = "ou=Sales Department,dc=mydomain,dc=local"

'Distinguished Name of the group to add the computers to
strTargetGroup = "cn=Sales Group,cn=Users,dc=mydomain,dc=local"

Set colItems = GetObject _
    ("LDAP://" & strComputerOU)

For Each objItem in colItems
    If objItem.Class = "computer" Then
      Set objGroup = GetObject ("LDAP://" & strTargetGroup)
    objGroup.Add(objItem.ADsPath)
    End If
Next
0
 

Author Comment

by:AFAIT
Comment Utility
I am not so sure that I want my Helpdesk staff to be using the NETDOM command to join computers to the domain.  Regarding the vbscript...that might work...I will give it a shot and report back.  I was really hoping there would be a better way other than a script though...

I do thank you both for the feedback and let you know the result.  (I also need to take some time to read all three of the articles posted).
Thank you again.
0
 

Author Comment

by:AFAIT
Comment Utility
Hey Shift-3,

That script worked fantastic!  I will use that.  Thank you both very much for your help.
...awarding points...
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Nslookup is a command line driven utility supplied as part of most Windows operating systems that can reveal information related to domain names and the Internet Protocol (IP) addresses associated with them. In simple terms, it is a tool that can …
Sometimes you might need to configure routing based not only on destination IP address, but also on a combination of destination IP address (or hostname) and destination port number. I will describe a method how to accomplish this with free tools. …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now