Announcement

Collapse
No announcement yet.

Moving from one OU in AD to another with a VBS .wsf file designed for MDT

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Moving from one OU in AD to another with a VBS .wsf file designed for MDT

    Hey guys, new here trying to learn what I can.


    I use MDT to image computers and add them to a domain and specific OU. However the issue I am facing is all of the OUs in my domain have a legal disclaimer page that is blocking the task sequence from continuing.

    What I did was built an OU specifically for deployments that disregards that policy. However what my goal was at the end of the task sequence I add it to an AD group using a script file I found online that works flawlessly. I've attempted to modify it to do the same thing except change the OU rather than adding it to an ADGroup, but my VBS knowledge is having trouble reading the code to make the modifications, I just don't know all the variable meanings yet.

    This is the original script I'm looking at that uses the customsettings.ini file to add it to the AD group. I've added the variables to the .ini file that will be used with the newly built script. I just know there is something basic I'm missing here.

    Here is the .ini file settings in MDT I'm using currently:

    [Settings]
    Priority=Default
    Properties=MyCustomProperty, ADGroup, MoveOU

    [Default]
    _SMSTSOrgName=Running %TaskSequenceID% on %OSDComputername%

    SkipBDDWelcome=YES
    UserID=****
    UserPassword=****
    UserDomain=****
    SkipAdminPassword=YES
    OSInstall=Y
    SkipCapture=NO
    AdminPassword=****
    SkipAdminPassword=YES
    SkipProductKey=YES
    SkipComputerBackup=YES
    SkipBitLocker=YES
    SkipTimeZone=YES
    SkipLocaleSelection=YES
    TimeZoneName=Central Standard Time
    SkipUserData=YES

    JoinDomain=****
    DomainAdmin=****
    DomainAdminDomain=****
    DomainAdminPassword=****

    MachineObjectOU=OU=****,DC=****,DC=com

    ;AD Group variable for New Workstations AD group
    ADGroup = LDAP://CN=****,OU=****,OU=****,OU=****,DC=****,DC=****

    ;Move OU variable for Workstations OU move
    MoveOU = LDAP://OU=****,DC=****,DC=****

    SkipSummary=YES
    SkipFinalSummary=YES
    FinishAction=REBOOT



    This is the script I use for the ADGroup one, I was hoping I could do something similar for the MoveOU one, so I could call it at the end of my task sequence, followed by a gpupdate and then the reboot to log out the local admin account.

    <job id="Add-Computer-To-Group">
    <script language="VBScript" src="ZTIUtility.vbs"/>
    <script language="VBScript">

    Option Explicit

    Dim iRetVal

    On Error Resume Next
    iRetVal = ZTIProcess
    ProcessResults iRetVal
    On Error Goto 0

    Function ZTIProcess()

    iRetVal = Success
    ZTIProcess = iRetval

    Const ADS_PROPERTY_APPEND = 3

    Dim sGroup, oGroup, oADSYS, sComputerDN

    'Set AD Group

    oLogging.CreateEntry "Add current computer to AD Security Group", LogTypeInfo

    sGroup = oEnvironment.Item("ADGroup")

    Set oGroup = GetObject (sGroup)

    oLogging.CreateEntry "Target Group Distinguised Name is: " & sGroup , LogTypeInfo


    'Get current Computers Distinguised Name from Active Directory

    oLogging.CreateEntry "Getting Computers Distinguised Name from Active Directory", LogTypeInfo

    Set oADSys = CreateObject("ADSystemInfo")

    sComputerDN = oADSys.ComputerName

    oLogging.CreateEntry "Computer Object Distinguised Name is: " & sComputerDN , LogTypeInfo

    oLogging.CreateEntry "Adding computer object to group: " & sGroup, LogTypeInfo

    'Add Member to Group

    oGroup.PutEx ADS_PROPERTY_APPEND, "member", Array(sComputerDN)

    oGroup.SetInfo

    oLogging.CreateEntry "Finished script.", LogTypeInfo

    End Function

    </script>
    </job>


    Is this possible? Please help or advise.
Working...
X