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
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 71

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
New IP's needed ASAP 6 79
User Account Question 6 45
Active Directory permissions 5 32
IF statement on a PowerShell Script 2 22
While rebooting windows server 2003 server , it's showing "active directory rebuilding indices please wait" at startup. It took a little while for this process to complete and once we logged on not all the services were started so another reboot is …
A hard and fast method for reducing Active Directory Administrators members.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

740 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