Input text file/cvs/xls to VB script to modify bulk users logon workstations

Answered Input text file/cvs/xls to VB script to modify bulk users logon workstations

All Replies

  • Thursday, August 30, 2012 5:46 PM
    Moderator
     
     Answered

    And your question is?

    Wait, you're not suggesting that some unpaid volunteer should write you a script, are you?  If that's what you have in mind, I have to tell you that that's not how it works around here.  Please read the first two permanent posts in this forum, follow their guidance and come back with specific questions about any particular part of the solution that you're having problems with.  Then I'm pretty sure someone would be more than happy to give you some help. 

    As a starter, try looking up file handling in the Windows Script Host documentation.  It illustrates the reading of a text or CSV file.  I would suggest that Excel is beyond your skill or need level right now, though it is entirely doable.


    Tom Lavedas


  • Thursday, August 30, 2012 8:46 PM
    Moderator
     
     Answered Has Code

    The attribute of AD user objects for specifying computers they are allowed to logon to is userWorkstations. This is a single-valued string attribute. The value should be the NetBIOS names of the allowed computers, comma delimited (in one string). You need to bind to each user object (using the distinguished name) and assign a value. In brief:

    Set objUser = GetObject("LDAP://cn=Jim Smith,ou=West,dc=MyDomain,dc=com")
    objUser.userWorkstations = "Alpha,Beta,Gamma,Zeta"
    objUser.SetInfo

    -----

    Will the spreadsheet have user DN's in one column and the new value for userWorkstations in another column? Or, will all users get the same value for userWorkstations? If your source is "pre-Windows 2000 logon names" (sAMAccountName instead of DN), the script will need to convert this into distinguishedName (DN).

    You can find examples of VBScript programs to read values from a spreadsheet in the Script gallery. I have a simple example linked here:

    http://www.rlmueller.net/Read%20from%20Excel.htm

    This example is actually a good one for your situation, as it reads user DN's and other values, binds to each user, and assigns the values to attributes. You just need to modify for the userWorkstations attribute.


    Richard Mueller - MVP Directory Services