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
Set objOU = GetObject ("LDAP://OU=PATH,OU=PATH,OU=PATH,OU=PATH,DC=PATH,DC=PATH")
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
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
------------------------------------------------------------------
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
Set objOU = GetObject ("LDAP://OU=PATH,OU=PATH,OU=PATH,OU=PATH,DC=PATH,DC=PATH")
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
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
------------------------------------------------------------------