Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

dfrey (IS/IT--Management) (OP)
22 Jun 06 15:09
I am working on my companies workstation image.  I am trying to write a script for all Computers built with this image to add themselves to a specific Active Directory Group.  At first I thought a simple bat file using "dsmod" would work.  However I realized I needed a way to make the batch file to vary with the computers name.  Any suggestions would be appreciated...

DF
tsuji (TechnicalUser)
23 Jun 06 3:00
What have you tried sofar?
dfrey (IS/IT--Management) (OP)
23 Jun 06 10:30
I am not sure where to begin... this is what I tried to this point.

Set objGroup = GetObject _
    ("LDAP://cn=XP Coversion;ou=Groups;dc="Company",dc=com")
'  "XP Conversion" is the group I would like it to be placed
objGroup.PutEx ADS_PROPERTY_APPEND, _
    "member", Array("cn="ComputerName",ou=Computers ,ou=Minneapolis,ou=Central Region,dc="company", dc=com")
objGroup.SetInfo
dfrey (IS/IT--Management) (OP)
23 Jun 06 10:34
I forgot to put on the initial post that I figured a Batch file wouldnt work so I attempted to write a vbs script to get it to work.  I figured if I could make the script work with one computer then I could move on to making it work on any computer the script was run on.
tsuji (TechnicalUser)
23 Jun 06 11:10
I'm glad you show at least something for the forum to have something anchored as a starting point. It is done like this.

Set objGroup = GetObject _
    ("LDAP://cn=XP Coversion,ou=Groups,dc=Company,dc=com")
'  "XP Conversion" is the group I would like it to be placed
Set ocomputer=GetObject _
    ("LDAP://cn=ComputerName,ou=Computers," & _
    "ou=Minneapolis,ou=Central Region,dc=company,dc=com")
objGroup.add ocomputer.adspath
'or simply this instead
'objGroup.add "LDAP://cn=ComputerName,ou=Computers," & _
'    "ou=Minneapolis,ou=Central Region,dc=company,dc=com"
'add error control as needed and not to forget cleaning up

dfrey (IS/IT--Management) (OP)
23 Jun 06 12:33
This is what I got so far... The script fails at line 16.  Am I doing something wrong with my COMPUTERNAME variable?

Function ADSysInfo(strADSysInfo)
 Dim ADsys
   Set ADsys = CreateObject("ADSystemInfo")
   Select case (ucase(strADSysInfo))
      Case "COMPUTERNAME"
         ADSysInfo = ADsys.ComputerName
   End Select
End Function
'
Const ADS_PROPERTY_APPEND = 3
'
Set objGroup = GetObject _
    ("LDAP://cn=Domain XP Coversion,ou=Groups,dc="company name",dc=com")
objGroup.PutEx ADS_PROPERTY_APPEND, _
    "member", Array("cn="&COMPUTERNAME&",ou=Computers ,ou=Minneapolis,ou=Central Region,dc="company name", dc=com")
objGroup.SetInfo
tsuji (TechnicalUser)
23 Jun 06 12:42
I can only conclude you did not read my answer (which I don't claim perfect.)
dfrey (IS/IT--Management) (OP)
23 Jun 06 13:03
Thanks for the advice this worked....

Set objNetwork = CreateObject("Wscript.Network")
strcomputername = ucase((objnetwork.computername))
msgbox  strcomputername
Const ADS_PROPERTY_APPEND = 3
Set objGroup = GetObject _
    ("LDAP://cn=Domain XP Coversion,ou=Groups,dc=Company name,dc=com")
objGroup.PutEx ADS_PROPERTY_APPEND, _
    "member", Array("cn="&strcomputername&",ou=Computers ,ou=Minneapolis,ou=Central Region,dc=Company name, dc=com")
objGroup.SetInfo
mrmovie (TechnicalUser)
26 Jun 06 11:13
i would prob use the WinNT provider in your case, well i only say that because you are making a implicit link between a machines netbios name and its LDAP ADsPath....this link will not always hold true

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close