Jump to content
Sign in to follow this  
DJ VenGenCe

Create A Computer Account In Ad Inside Of A Specific Container

Recommended Posts

DJ VenGenCe

I want to implement this Idea into a Script.

Are there any programs out there that would help?

This is what I got in my AD.. OUs...

- Domain

- Workstations

- Desktops





- Laptops





If I wanted to Create a computer account In VBScript, It would begin like this..

For Desktops

strOu = "Desktops.Workstations.Domain.com

For Laptops

strOu = "Laptops.Workstations.Domain.com

Any ideas on how I could Script this? I've seen VBScripts, but nothing to "suit" my likings.

Oh yea, I found this code..

' ComputerOU .vbs
' Sample VBScript to create a computer in Computers .
' Author Guy Thomas http://computerperformance.co.uk/
' Version 2.3 - May 2005
' ------------------------------------------------------'
Option Explicit
Dim strComputer, strOU
Dim objRootLDAP, objContainer, objLeaf, objShell

strComputer = "XPSimpleOU"
strOU = "OU=Accounts ," ' Note the comma

' Bind to Active Directory, Computers container.
Set objRootLDAP = GetObject("LDAP://rootDSE")
Set objContainer = GetObject("LDAP://" & strOU & _

' Build the actual computer.
Set objLeaf = objContainer.Create("Computer", "cn=" & strComputer)
objLeaf.Put "sAMAccountName", strComputer & "$"
objLeaf.Put "userAccountControl", 4096

' Optional section to launch Active Directory Uses and Computers
Set objShell=CreateObject("WScript.Shell")
objShell.Run "%systemroot%\system32\dsa.msc"


' End of Sample ComputerOU VBScript .

And this:

' This VBScript code creates a computer object.

' ---------------------------------------------------------------
' From the book "Active Directory Cookbook" by Robbie Allen
' Publisher: O'Reilly and Associates
' ISBN: 0-596-00466-4
' Book web site: http://rallenhome.com/books/adcookbook/code.html
' ---------------------------------------------------------------

strBase = "<ParentComputerDN>"  ' e.g. cn=Computers,dc=rallencorp,dc=com
strComp = "<ComputerName>"    ' e.g. joe-xp
strDescr = "<Description>"    ' e.g. Joes Windows XP workstation
' ------ END CONFIGURATION ---------


set objCont = GetObject("LDAP://" & strBase)
set objComp = objCont.Create("computer", "cn=" & strComp)
objComp.Put "sAMAccountName", strComp & "$"
objComp.Put "description", strDesc
objComp.Put "userAccountControl", ADS_UF_WORKSTATION_TRUST_ACCOUNT
Wscript.Echo "Computer account for " & strComp & " created"
Edited by DJ VenGenCe

Share this post

Link to post
Share on other sites

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this