Jump to content

Create A Computer Account In Ad Inside Of A Specific Container


Recommended Posts

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

DESKTOPNAME1

DESKTOPNAME2

DESKTOPNAME3

DESKTOPNAME4

- Laptops

LAPTOPNAME1

LAPTOPNAME2

LAPTOPNAME3

LAPTOPNAME4

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 & _
objRootLDAP.Get("defaultNamingContext"))

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

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

WScript.Quit

' 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
' ---------------------------------------------------------------

' ------ SCRIPT CONFIGURATION ------
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 ---------

' ADS_USER_FLAG_ENUM
Const ADS_UF_WORKSTATION_TRUST_ACCOUNT = &h1000

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
objComp.SetInfo
Wscript.Echo "Computer account for " & strComp & " created"
Edited by DJ VenGenCe
Link to comment
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

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...