Input text file/cvs/xls to VB script to modify bulk users logon workstations
-
Thursday, August 30, 2012 2:18 PM
Hi,
I want to modify 100 users logon workstation in single shot.
When I asked question in forum http://social.technet.microsoft.com/Forums/en-US/winservergen/thread/346231f3-6a68-4587-8ea6-8bffd0342895
I was redirected to the below scripting url, now I want to change 100users logon workstations using your script with input file as xls or whichever way you suggest, please help.
- Edited by Anil Kumar H Thursday, August 30, 2012 2:19 PM
All Replies
-
Thursday, August 30, 2012 5:46 PMModerator
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
- Edited by Tom LavedasModerator Thursday, August 30, 2012 5:48 PM typo
- Marked As Answer by IamMredMicrosoft Employee, Owner Monday, September 10, 2012 5:25 AM
-
Thursday, August 30, 2012 8:46 PMModerator
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
- Marked As Answer by IamMredMicrosoft Employee, Owner Monday, September 10, 2012 5:25 AM

