/build/static/layout/Breadcrumb_cap_w.png

Is there a script out there that will prompt for Domain name and use that variable with the join_domain .vbs?

I am currently trying to make one image on K2000 that will work with multiple company's, and I am stuck on adding the domain. If you guys have ideas please let me know. Thank you in advance.

0 Comments   [ + ] Show comments

Answers (1)

Posted by: jknox 9 years ago
Red Belt
0

Comments:
  • I went to the website, ran some tests, It prompted but didn't seem to add to the domain. maybe I inserted a few line wrong. But this is what i have.

    Option Explicit

    Dim strDomain, strUser, strPassword, strOU
    Dim objNetwork, strComputer, objComputer, lngReturnValue

    Const JOIN_DOMAIN = 1
    Const ACCT_CREATE = 2
    Const ACCT_DELETE = 4
    Const WIN9X_UPGRADE = 16
    Const DOMAIN_JOIN_IF_JOINED = 32
    Const JOIN_UNSECURE = 64
    Const MACHINE_PASSWORD_PASSED = 128
    Const DEFERRED_SPN_SET = 256
    Const INSTALL_INVOCATION = 262144

    ' Prompt for credentials.
    strDomain = InputBox("Enter name of domain")
    strUser = "USER"
    strPassword = "PASSWORD"

    ' Specify the OU where the computer object will be created.
    strOU = "ou=Computers,dc=(strDomain),dc=com"

    ' Retrieve NetBIOS name of local computer.
    Set objNetwork = CreateObject("WScript.Network")
    strComputer = objNetwork.ComputerName

    Set objComputer = GetObject("winmgmts:" _
    & "{impersonationLevel=Impersonate,authenticationLevel=Pkt}!\\" & _
    strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
    strComputer & "'")

    lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, strDomain & "\" & strUser, strOU, _
    JOIN_DOMAIN + ACCT_CREATE)

    Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)

    Select Case lngReturnValue
    ' Some return code values (added 04/05/2010).
    Case 0
    Wscript.Echo "Success joining computer to the domain!"
    Case 5
    Wscript.Echo "Access is denied"
    Case 87
    Wscript.Echo "The parameter is incorrect"
    Case 110
    Wscript.Echo "The system cannot open the specified object"
    Case 1323
    Wscript.Echo "Unable to update the password"
    Case 1326
    Wscript.Echo "Logon failure: unknown username or bad password"
    Case 1355
    Wscript.Echo "The specified domain either does not exist or could not be contacted"
    Case 2224
    Wscript.Echo "The account already exists"
    Case 2691
    Wscript.Echo "The machine is already joined to the domain"
    Case 2692
    Wscript.Echo "The machine is not currently joined to a domain"
    Case Else
    Wscript.Echo "Unknown error"
    End Select - Jstump 9 years ago

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ