Solved

How I create a script to restrict computer acces filling the "Log On To" ("userWorkstations") field, from a text file

Posted on 2009-05-19
3
258 Views
Last Modified: 2012-05-07
Hello my dear experts,
I use this script to fill the "Log on To" field on AD:
Set objUser = GetObject _
  ("LDAP://cn=user (USR),ou=3rd OU,ou=2nd,ou=1st ou,dc=bpco,dc=com")
 objUser.Put "userWorkstations", "A,B,C,D,E"
objUser.SetInfo
Because of frequent changes inside the net, a very cool improvement will be to be able to use this same script, but allowing to pull the userWorkstations from a file text with a pre-defined computer ser list
Can you help me?
0
Comment
Question by:bpco
  • 2
3 Comments
 
LVL 70

Accepted Solution

by:
Chris Dent earned 125 total points
ID: 24431336

Hey,

Should be pretty straight-forward.

Const WORKSTATION_FILE = "TheList.txt"

Dim objFSO : Set objFSO = CreateObject("Scripting.FileSystemObject")
Dim objFile : Set objFile = objFSO.OpenTextFile(WORKSTATION_FILE, 1, False, 0)

strWorkstations = objFile.ReadAll()

Now it's just down to how you want the file to be formatted. If it's just a list it can be popped straight in:

Set objUser = GetObject _
  ("LDAP://cn=user (USR),ou=3rd OU,ou=2nd,ou=1st ou,dc=bpco,dc=com")
objUser.Put "userWorkstations", strWorkstations
objUser.SetInfo

Where the list in the file would be:

workstation1,workstation2,workstation3

Chris
0
 

Author Comment

by:bpco
ID: 24441046
Worked very well, thanks Chris!
0
 

Author Comment

by:bpco
ID: 24502374
I've should added more points if there were more solutions, like using csv tables for example instead of plain txt files... however, I've got the script well running
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Resolve DNS query failed errors for Exchange
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question