No announcement yet.

Moving computer account

  • Filter
  • Time
  • Show
Clear All
new posts

  • Moving computer account


    I have been looking for a script that will determine if the computer account is either a laptop or a computer and then move it to the right OU's, the way or active directory is setup laptops and computers are in differents ou's (diferrent gpo's)

    Computer account for laptop's start with LXXXX
    Computer account for computer start with PXXXX or PCXXXX
    Computer account for Visual computer start with VXXXX

    so unless i am wrong a 3 way condition will be needed for this to work.

    Thanks for you help

  • #2
    Re: Moving computer account

    If you want it to run this at startup (startup script (?)), you need to provide Admin credentials in the scriptcode.



    If you don't want to use multiple GPO's, then the main filtering can take place in the script:

    DIM sComputerName
    Set objNetwork = WScript.CreateObject("WScript.Network")
    sComputerName = objNetwork.ComputerName
    If NameStartWith("L") Then
      strOU = "...<Distinguest Name of the destination OU 1>..."
    ElseIf NameStartWith("P") Then
      strOU = "...<Distinguest Name of the destination OU 2>..."
    ElseIf NameStartWith("V") Then
      strOU = "...<Distinguest Name of the destination OU 3>..."
    Else wscript.quit
    End If
    Function NameStartWith(beginletters)
     ' For verifying the begin character(s) you
     ' can use a regular expression.
     Set re = new regexp  'Create the RegExp object
     re.Pattern = "^" & beginletters
     re.IgnoreCase = true
     If re.Test(sComputerName) then
       NameStartWith = True
       NameStartWith = False
     End If
    End Function
    Or else, to identify the computer type you can also use the Chassis Type.

    Last edited by Rems; 13th May 2008, 21:42.

    This posting is provided "AS IS" with no warranties, and confers no rights.


    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts