Assign everyone to the local user group using a log on script

Posted on 2005-04-13
Last Modified: 2010-04-13
I have taken over an administrator job for a company.  the old network admin had users assigned to the local admin group on their PC's.  Is there a log on script out there that will assign all users in an OU to the local users group?
Question by:scrosbie
    LVL 70

    Accepted Solution


    Domain Users are normally members of the Local Users group for a member machine - this is generally inclusive of all users in AD unless membership has been significantly changed.

    Are you attempting to strip out the members of the Local Administrators group and re-add them to Users?

    This script works best as Administrator, I haven't tested it with local administrator only, it won't do anything as a normal user.

    Otherwise this will add the contents of a specific OU to the local users group:

    ' Connect to the OU in AD and get the users

    Set objOU = GetObject("LDAP://cn=Users,dc=yourdomain,dc=com")
    objOU.Filter = Array("user")

    ' Connect to the Users group on the local computer

    Set objGroup = GetObject("WinNT://Localhost/Users,group")

    For Each objUser in objOU
          ' Now the fun bit, reconnect to the user account in the interface objGroup likes

          Set objDomainUser = GetObject("WinNT://<Domain Name>/" & objUser.sAMAccountName & ",user")
          Set objDomainUser = Nothing

    Set objUser = Nothing
    Set objGroup = Nothing
    Set objOU = Nothing

    Let me know how you get on.



    Author Comment

    Im trying to strip everyone who has local admin rights.  THis looks like its on the right track... I will test and let you know ASAP

    Author Comment

    Worked had to tweak a little but worked well done
    LVL 70

    Expert Comment

    by:Chris Dent

    Happy it helped :)
    LVL 1

    Expert Comment

    Just curious if that script was able to remvoe them from the local admin group. I tryed and it looks like it added them to the local users group, but they are still in local admin. Any changes you made in that script are appreciated. Thanks

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
    Digital marketing agencies have encountered both the opportunities and difficulties that emerge from working with a wide-ranging organizations.
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    759 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

    11 Experts available now in Live!

    Get 1:1 Help Now