locked
Auto join in the computer group when the computer join in the AD RRS feed

  • Question

  • i have one script for computer join in the AD and OU when new computer come in.

    now i got new request , when the computer join in the AD, meantime need to join in one group.

    my script as below:

    ' Join a Computer to a Domain


    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
     
    strDomain = "test.com"
    strPassword ="P@ssw0rd"
    strUser = "Testadmin"
    strOU = "OU=Test,DC=test,DC=com"
     
    Set objNetwork = CreateObject("WScript.Network")
    strComputer = objNetwork.ComputerName
     
    Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
        strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
            strComputer & "'")
     
    ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
        strPassword, strDomain & "\" & strUser, strOU, _
            JOIN_DOMAIN + ACCT_CREATE)


    Wscript.echo "Please restart this computer manually."

    how can i do?  Add the strGroup in this script?

    Tuesday, October 10, 2017 9:57 AM

Answers

All replies