WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Samples from Users

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Add Computer to an Active Directory Group

Keywords:  Add Computer Active Directory Group ADSI  LDAP  dsGetProperty dsFindPath dsMoveObj 

; Add Computer to an Active Directory Group
dsSetCredent("mylogin", "mypasword")
ServerName = StrSub( Environment("LOGONSERVER"), 3, 100)
ServerDn = dsGetProperty( "LDAP://rootDSE", "defaultNamingContext" )
ServerPath = "LDAP://": ServerName: "/" : ServerDN
ComputerName = StrUpper( Environment( "COMPUTERNAME" ) )
ComputerPath = dsFindPath( ServerPath, "(&(objectCategory=Computer)(CN=" : ComputerName : " ))" )
GroupPath = dsFindPath( ServerPath, "(&(objectCategory=group)(CN=active directory group))" )
dsAddToGrp( ComputerPath, GroupPath )

Article ID:   W17540
Filename:   Add Computer to an Active Directory Group.txt
File Created: 2010:06:03:08:22:24
Last Updated: 2010:06:03:08:22:24