Announcement

Collapse
No announcement yet.

Move Computers to OU vbscript

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

  • Move Computers to OU vbscript

    Hello folks.
    I am trying to make a variation of a script I found on Script Center. The goal of the script is to move/change the location of a computer object in AD.
    I have tested the script and it works if I specify the name of the computer object I want to move (as in the MS example below). But what I really need to do is use a wildcard, thus all computers object containing *CHI in their name would be moved to the Chicago IL OU. I have tested the script using the wildcard and it does not work. It says "There is no such object on this server"

    Question 1: Can I use a wildcard in a VBScript?
    Question 2: Can I string multiple VBScripts together into one grande enchilada VBScript?


    FROM Script Center:
    VBScript to Move a Computer Account

    Description: Moves a computer account from the Computers container in Active Directory to the Finance OU in the same domain.
    *******
    Set objNewOU = GetObject("LDAP://OU=Finance,DC=fabrikam,DC=com")

    Set objMoveComputer = objNewOU.MoveHere _
    ("LDAP://CN=atl-pro-03,CN=Computers,DC=fabrikam,DC=com", "CN=atl-pro-03")

    *******
    My Variation:

    A variation for our environment might look like this.
    This variation would move all computers containing *CHI in their name to the Chicago IL OU.
    *******
    Set objNewOU = GetObject("LDAP://OU=Computers,OU=Chicago,OU=IL,OU=USA,DC=NA,DC=BOBO ,DC=com")

    Set objMoveComputer = objNewOU.MoveHere _
    ("LDAP://CN=*CHI,CN=Computers,DC=NA,DC=BOBO,DC=com", "CN=*CHI")

    *******
    I have tested my variation of the the script using the wildcard and it does not work. It says "There is no such object on this server"

    Thanks for your thoughts on this issue. I have posted this issue in the AD forum as well. Sorry for the cross-posting, I initially thought this was an AD issue but then realized it was a scripting question.
    -Dave
Working...
X