How to evaluate for computer OU membership in Logon Script

Posted on 2004-11-03
Last Modified: 2008-02-01
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.
Question by:charlesejones
    LVL 10

    Accepted 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
    LVL 1

    Author Comment

    Excellent!  Thanks so much!

    Expert Comment

    This script does not work for me.. The strGroup variable remains empty when running.

    Any ideas or diffrent solution?

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    The HP utility "HP Lights-Out Online Configuration Utility for Windows Server 2003/2008" could be of great use when it comes to remotely configure a HP servers ILO WITHOUT rebooting the server. We would only need to create and run scripts using thi…
    I've always wanted to allow a user to have a printer no matter where they login. The steps below will show you how to achieve just that. In this Article I'll show how to deploy printers automatically with group policy and then using security fil…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now