No announcement yet.

Moving Objects

  • Filter
  • Time
  • Show
Clear All
new posts

  • Moving Objects

    Hi Guys, I have a huge task ahead of me where I need to move about 700 to 900 users to a different OU and I need to add them into a group and remove them from another. With the lack experence the only thing I can come up with is using some DS commands dsmove,dsmod group,-addmbr and -remmbr. Just wondering whats the best way I been trying to get my head around using a CSVDE file but just cant put it all together. can any one provide a link to example or any suggestion will help.

    Thanx in advance

  • #2
    Re: Moving Objects

    I've done similar things before like bulk password changes etc and it's been a while. The basics are the same though. Just remember to check at each stage that the syntax is as it should be.

    Using the ds commands output to a text file the list of users. Tweak the list to be comma delimited and import into excel now edit the various fields as required until you have the correctly formatted lines.

    Save as a txt file again, check the syntax and include in a batch file and run it.

    You can add the dsmove command at any stage to the lines. Well you get the general idea.

    a couple of points of reference below. Good Luck
    The Univurse is still winning!

    W2K AD, WSUS, RIS 2003. ISA also AVG Server
    ** If contributors help you, recognise them and give reputation points where appropriate **


    • #3
      Re: Moving Objects

      lol I hope it doesn't seem like I've just come on this forum to plug my software (as I just responded to another post with pretty much this same answer) but I recently wrote an application that can do this. It is completely free for anyone to use, I wrote it purely to help other IT Pro's out, and although it is intended to be used to clean up inactive user/computer accounts you can also just use it as a basic bulk account modification tool.
      In the next version you will be able to perform more than one action at once but for now you would have to just do each action one after another... but basically all you would do is specify the OU with the accounts in and click Search, from the search results select which accounts you want to perform an action on, then simple select an action from the Actions drop down list (the ones you would be interested in would obviously be Move, Add To Group, and Remove From Group) then there you go job done Anyway, if you are interested you can find out more info and a free download link here:

      Hope it helps and if you do decide to use it I would love to hear any feedback you have

      Software for IT Pros that I've written:

      My blog:


      • #4
        Re: Moving Objects

        Use This:

        on error resume next
        Const Formyfile = 1
        Const ADS_SCOPE_SUBTREE = 2
        Set con = CreateObject("ADODB.Connection")
        Set com = CreateObject("ADODB.Command")
        Set rsset = CreateObject("ADODB.recordset")
        con.Provider = "ADsDSOObject"
        con.Open "Active Directory Provider"
        com.ActiveConnection = con
        com.Properties("searchscope") = 2
        com.Properties("Page Size") = 100000
        com.Properties("Searchscope") = ADS_SCOPE_SUBTREE
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set ts = fso.OpenTextFile("C:\ADdump.txt",formyfile,True)
        Set objOU = GetObject("LDAP://OU=Test,DC=XYZ,DC=COM")

        do While Not ts.AtEndOfStream
        strUsersID = Trim(ts.ReadLine)

        strQuery = "<LDAP://DC=XYZ,DC=COM>;(&(objectclass=user)(cn=" & strUsersID & "));ADsPath"
        Com.CommandText = strQuery
        Set rsset = com.Execute

        strADsPath = rsset.Fields("ADsPath").value
        objOU.MoveHere strADsPath, vbNullString


        Save this as *.vbs and double click to run...

        * In above example C:\ADdump.txt is the file that will have user list to be moved in below format:


        **OU=Test,DC=XYZ,DC=COM has to be replace by the DN of target OU where users to be moved.

        ***C=XYZ,DC=COM has to be replaced by the DN of domain.

        Kapil Sharma
        Life is too short, Enjoy It.