'========================================================================== ' ' VBScript: AUTHOR: Ed Wilson , MS, 5/8/2006 ' ' NAME: CreateComputer.vbs 'ver.1.2 renamed variables, and added err object. ' COMMENT: Key concepts are listed below: '1.This script creates an OU. IT MUST have access to Active Directory '2.The Domain is assumed to be nwtraders.msft. You would edit your '3.strDomain variable to add new name of your domain '4.You would edit value of strOUname to be name of your new Computer to create. '========================================================================== Option Explicit 'On Error Resume next Dim strProvider 'defines how will talk. Dim strOU ' path to where new object will be created Dim strDomain 'name of strDomain connecting to Dim strClass ' the class of object we are creating Dim strOUname 'name of object are creating Dim objDomain 'holds connection to adsi Dim objOU 'holds handle to create method strProvider = "LDAP://" strOU = "" 'when using is OU=mred, THE , would be required. strDomain = "ou=workstations,dc=nwtraders,dc=msft" strClass = "Computer" strOUname = "CN=MyMredComputer" Set objDomain = GetObject(strProvider & strOU & strDomain) WScript.echo strProvider & strOU & strDomain 'debug Set objOU = objDomain.create(strClass, strOUname) WScript.echo strClass & "," & strOUname 'debug objOU.put "sAMAccountName", funFix(strOUname) objOU.SetInfo objOU.put "userAccountControl",4128 objOU.setinfo If Err.number = 0 Then WScript.Echo(strOUname & " was created") Else If Err.number = "-2147019886" Then WScript.echo strOUname & " already exists" Else WScript.echo " error on the play " & Err.Number End If End If function funfix(strIN) funfix = Mid(strIN,4) End function