Re: Add domain user to local group script troubleshoot

From: Rick Kalifa (rkalifa_at_hotmail.com.NO_SPAM)
Date: 03/25/04


Date: Thu, 25 Mar 2004 13:54:27 -0600

This script works great!!

What I would like to with this is get a list of all the workstations, so I
can add the group I need to the local administrators.

In the past, I've exported a list, and ran a job against the list of
computers. However, I'd like to take it one step further and have the script
find the workstations dynamically and then apply the changes I need on that
workstation.

Any input here would be appreciated.

RK.

"Richard Mueller [MVP]" <rlmueller-NOSPAM@ameritech.NOSPAM.net> wrote in
message news:OChpsfiEEHA.3576@TK2MSFTNGP12.phx.gbl...
> mtothej wrote:
>
> > I am trying the following script to add a domain user to a local group:
> >
> > Set objGroup = GetObject _
> > ("WinNT://remotecomputer/Administrators")
> > Set objUser = GetObject _
> > ("LDAP://CN=username,OU=MyOU,OU=MyOU,DC=root,DC=mydomain,DC=org")
> > objGroup.Add(objUser.ADsPath)
> >
> > I get the following error:
> >
> > C:\Scripts\add_domain_user_to_local_group.vbs(5, 1) Active Directory: An
> invalid
> > Active Directory pathname was passed
> >
> > I know the ADsPath for the user is correct because I can retrieve
> properties from it. I know the objGroup path is correct because I can
> enumerate the current users in the group.
> >
> > Is something wrong in the last line? Am I on the right track or is there
> another way to add a domain user to a local group? Thanks :)
>
> You must bind to the user object with the WinNT provider. If the
> "cn=Username" user has sAMAccountName equal to "username", and the NetBIOS
> name of the domain is "MyDomain", then use
>
> Set objUser = GetObject("WinNT://MyDomain/username,user")
>
> The local group object's Add method does not understand an LDAP AdsPath.
>
> --
> Richard
> Microsoft MVP Scripting and ADSI
> HilltopLab web site - http://www.rlmueller.net
> --
>
>



Relevant Pages

  • Re: rename a local group in windows 2003
    ... If the script always runs on the computer where the local group is to be ... strComputer = objNetwork.ComputernName ... WinNT provider only rename domain groups, ...
    (microsoft.public.windows.server.scripting)
  • Re: Add Domain Users group to local Power Users group
    ... for scripts that add domain users / groups to local groups but haven't ... variable inside the script so that the script works on all computers. ... You pass the AdsPath of the new member to the method. ... ' Bind to the local group with the WinNT provider. ...
    (microsoft.public.scripting.vbscript)
  • Re: Disable/Delete unused workstations
    ... This script will remove inactive machine accounts in Active Directory ... > is there a way to automatically disable or delete workstations not used in ...
    (microsoft.public.win2000.group_policy)
  • Re: Add Domain Users group to local Power Users group
    ... for scripts that add domain users / groups to local groups but haven't ... variable inside the script so that the script works on all computers. ... You pass the AdsPath of the new member to the method. ... ' Bind to the local group with the WinNT provider. ...
    (microsoft.public.scripting.vbscript)
  • Re: Deploying Red Hat Workstations
    ... > can easily make changes to the workstations all at once. ... Have the central server push out to each host. ... > This script will contain any changes that I need to make. ... I would automate SCP from the server to a user account (not ...
    (Fedora)