MSFN Forum: Script to Add computers to "Log On To.." - MSFN Forum

Jump to content



Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Script to Add computers to "Log On To.." Rate Topic: -----

#1 User is offline   bbbngowc 

  • Member
  • PipPip
  • Group: Members
  • Posts: 127
  • Joined: 09-August 06

Posted 13 August 2009 - 07:25 AM

Hello,

I have about 500 users that need access to 3 new servers in our 2003 Windows Server Domain. I am looking for a script that will accomplish this for me. After a brief internet search I found this script. Anyone familiar with VB Scripting could tell me if this will work?

Dim strComputer, objUser, strWorkstations, arrNames, k, objOU

' Bind to user object.
Set objOU = GetObject _
("LDAP://DC=DOMAIN,DC=COM")
objOU.Filter = Array("user")

' Specify NetBIOS name of computer to add.
strComputer = "SERVER1,SERVER2,SERVER3"

For Each objUser in objOU
' Retrieve value of userWorkstations attribute.
strWorkstations = objUser.userWorkstations

' Check if new computer name already included.
arrNames = Split(strWorkstations, ",")
For k = 0 To UBound(arrNames)
If (LCase(strComputer) = LCase(arrNames(k))) Then
' This computer already included. Abort.
Wscript.Echo "User already allowed to logon to " & strComputer
End If
Next

' Append new computer name.
If (strWorkstations = "") Then
strWorkstations = strComputer
Else
strWorkstations = strWorkstations & "," & strComputer
End If

' Save new value.
objUser.userWorkstations = strWorkstations
objUser.SetInfo

Next

This post has been edited by bbbngowc: 13 August 2009 - 07:30 AM



#2 User is offline   bbbngowc 

  • Member
  • PipPip
  • Group: Members
  • Posts: 127
  • Joined: 09-August 06

Posted 13 August 2009 - 10:08 AM

I made some small modifications to the script and ran it. It works. Thanks for looking.

#3 User is offline   softmobi4all 

  • Newbie
  • Group: Members
  • Posts: 38
  • Joined: 09-May 08

Posted 22 September 2009 - 01:06 AM

Thanking

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



All trademarks mentioned on this page are the property of their respective owners
Copyright © 2001 - 2011 msfn.org
Privacy Policy