Add domain user to local group by command line

Question

  • I try the following command to add a domain user into local Administrators group of my Windows 7 computer and my computer has already joined domain.

    net localgroup administrators mydomain.local\user1 /add /domain

    It returns successful added, but I don’t find it in the local Administrators group.

    How can I do it?

    Thanks,

    Joe.

    Answers

    • Because you are using the /domain parameter you are executing the command on the PDC instead of on the local computer. Try this command:

      net localgroup administrators mydomain.local\user1 /add

      More information: http://technet.microsoft.com/en-us/library/cc725622(v=ws.10).aspx

      Examples

      The following example displays a list of all the local groups on the local server, type:

      net localgroup

      The following example adds a local group called Exec to the local user accounts database, type:

      net localgroup exec /add

      The following example adds a local group called Exec to the domain user accounts database, type:

      net localgroup exec /add /domain

      The following example adds the existing user accounts stevev, ralphr (from the Sales domain), and jennyt to the Exec local group on the local computer, type:

      net localgroup exec stevev sales\ralphr jennyt /add

      The following example adds the existing user accounts stevev, ralphr, and jennyt to the Exec group of a domain, type:

      net localgroup exec stevev ralphr jennyt /add /domain

      The following example displays users in the Exec local group, type:

      net localgroup exec

      The following example adds a comment to the Exec local group record, type:

      net localgroup exec /comment:"The executive staff."