Announcement

Collapse
No announcement yet.

VBScript to change Profile Attributes in AD after comparing the values in excel

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

  • VBScript to change Profile Attributes in AD after comparing the values in excel

    I have a script that pulls the attributes from AD and Excel, once checks if the same user is in both(AD and EXcel) It modifies the "description" and "st" attributes. But there is something that is not quiet well, because it only changes one user. I think the problem is in objUser, because it does not change the member of the group. In other words, objUser keep the same user all the time.

    Does anyone has an idea?
    Attached Files

  • Rems
    replied
    Re: VBScript to change Profile Attributes in AD after comparing the values in excel

    This is what your script currently is doing (understandable it was actually doing something),
    Code:
    For each unkown_object in an not existing collection of objects   (will raise an error!)
    
       Do
    
         select the next name from excel sheet (one name per round)
    
         query *all* users in the OU and its subOU's to create a new record set.
    
         go to the first record in the newly created recordset
         compare the name from that first record with the name currently read from excel
         If is a match then do make the changes to the unkown_object
    
       Loop  <- iterate through the rows of the sheet
    
    Next
    while the script should do,

    Code:
    query *all* users in one OU (and its subOU's if desirable), create one recordset
    
    go to the first record in the recordset
    
    Do
    
        get the name from record
    
        compare this name with the names on the excel sheet,
        (iterate through the rows of the sheet)
          If is a matching name was found then Bind to the user object 
          and make the changes
    
        go to the next record in recordset
    Loop  <- iterate through the recordset
    OR
    Code:
    collect all user objects from one OU
    
    For each userobject in the collection of userobjects
       get the userobject's.samaccountname
    
       compare the name with the names on the excel sheet
       (iterate through the rows of the sheet)
         If is a matching name was found then do the changes for the user
    
    Next  <- iterate through the collection of userobjects
    To find possible other issues, remove both lines "On Error Resume Next" from the script.


    [edit] And do indent ALL code blocks in the script, and remove lines that are comment-out. How it is now is hard to follow.


    \Rems
    Last edited by Rems; 1st July 2010, 22:54.

    Leave a comment:


  • vonPryz
    replied
    Re: VBScript to change Profile Attributes in AD after comparing the values in excel

    Too long, didn't read.

    Try running the script in debug mode. You can step through code and see what's going on. Use the //x parameter (yes, two froward slashes) Like so: csrcript //x script.vbs.

    -vP

    Leave a comment:

Working...
X