Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 247
  • Last Modified:

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

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
AFAIT
Asked:
AFAIT
  • 2
1 Solution
 
SamuraiCrowCommented:
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
 
Shift-3Commented:
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
 
AFAITAuthor Commented:
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
 
AFAITAuthor Commented:
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 is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now