Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Remove specific computer name in Logon Workstation from from all users in AD, with VBScript

Remove specific computer name in Logon Workstation from from all users in AD, with VBScript

Remove specific computer name in Logon Workstation from from all users in AD, with VBScript

In the users in our AD we have a specific computer name that result in only the user can logon to that very computer, called logon workstation. We also have a couple computers that are for "loan" if someone forgot theirs, that are added in the logon workstation besides with the specific computer that they already own.

There is a VBScript that we use every time a X amount of people start to work here so they also can access the loan PC (The VBScript add a self defined computer name to logon workstation to all the user). What we want help with is a VBScript that does actual the opposite, also remove that loan PC name from logon workstation from all the users. I will post the VBScript that add a specific computer name to Logon Workstation to all users if someone needs it or to get a bigger picture. Thanks


Option Explicit

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

' Bind to user object. Bytt ut OU=A,OU=4
objOU.Filter = Array("user")

' Specify NetBIOS name of computer to add.
strComputer = "XXXXXX"

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

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

' Save new value.
objUser.userWorkstations = strWorkstations



Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close