• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 808
  • Last Modified:

How to evaluate for computer OU membership in Logon Script

We are currently using Windows Scripting Host for our logon scripts with great success.  However, I have a unique situation with certain users.  Our environment is Windows 2003 Terminal Services in a Windows 2000 Native network.

All of our terminal servers are in a security group called TSFarm01.  I need to be able to check if a user is logging onto a computer in that security group to determine what icons to place on their desktop.  What I need is the exact syntax for a WSH .vbs file to determine the computer security group membership that the user is logging into.
1 Solution
Try this:

-- script start --

Const TSFARM01 = "cn=TSFarm01"

Set wshNetwork = CreateObject("WScript.Network")
Set ADSysInfo = CreateObject("ADSystemInfo")
Set CurrentComputer = GetObject("LDAP://" & ADSysInfo.ComputerName)
if isarray(CurrentComputer.MemberOf) then
  strGroups = LCase(Join(CurrentComputer.MemberOf))
  strGroups = LCase(CurrentComputer.MemberOf)
end if

If InStr(strGroups, TSFARM01) Then
  'computer belongs to TSFarm01 group, do what you need to
End If

-- script end --

hope this helps
charlesejonesAuthor Commented:
Excellent!  Thanks so much!
This script does not work for me.. The strGroup variable remains empty when running.

Any ideas or diffrent solution?

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now