"jnet77" <jnet77@xxxxxx> wrote in message
> Thanks for the response, and what you suggested is originally how the
> worked. The problem was, though, if I had 500 students and the 100th one
> already had the computer, the script would end at student 100. That meant
> the other 400 wouldn't get the new computer added.
> I need the script to only not execute on a user when the computer is
> found, but then go on and move to the next user.
> Your assistance in advance is appreciated.
Then one solution would be a boolean variable to indicate if the name is
found. For example (in part):
For Each objUser in objOU
' Retrieve value of userWorkstations attribute.
strWorkstations = objUser.userWorkstations
' Check if new computer name already included.
arrNames = Split(strWorkstations, ",")
blnFound = False
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
blnFound = True
If (blnFound = False) then
' Append new computer name.
If (strWorkstations = "") Then
strWorkstations = strComputer
strWorkstations = strWorkstations & "," & strComputer
' Save new value.
objUser.userWorkstations = strWorkstations
Note that the "Exit For" statement exits from the inner "For" statement, not
the outer "For Each".
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net