Announcement

Collapse
No announcement yet.

add AD user to local admins group on multiple servers

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • add AD user to local admins group on multiple servers

    Hi,
    I need to add AD user to local admins group on multiple servers.

    I found this:

    " Needed to add a user to the local administrators on 16 citrix servers, below is the code if you need it.
    psexec @servers.txt cmd /c “net localgroup Administrators /add domain\username”
    this doesnt work with multiple usernames at one time.
    get psexec here: http://www.sysinternals.com
    servers.txt is a text file containing a list of servers, i.e:
    server1
    server2
    etc "

    But when run it, I get the error (see below).
    When run only "net localgroup Administrators /add domaine\hpsim" on the same pc, the command executed successfully. Why it complains about "net" command?

    I guess no need to translate the error message from French

    C:\addadmin>psexec @servers.txt cmd /c "net localgroup Administrators /add domaine\hpsim"
    PsExec v1.98 - Execute processes remotely
    Copyright (C) 2001-2010 Mark Russinovich
    Sysinternals - www.sysinternals.com
    \\xxx00s22666:
    '"net' n'est pas reconnu en tant que commande interne
    ou externe, un programme exécutable ou un fichier de commandes.
    cmd exited on csssjr00s22666 with error code 1.
    "When you hit a wrong note it's the next note that makes it good or bad". Miles Davis

  • #2
    Re: add AD user to local admins group on multiple servers

    Originally posted by mla View Post
    psexec @servers.txt cmd /c “net localgroup Administrators /add domain\username”
    [...]
    The above command contains curly double-quote signs, always use straight double-quote sigs on the command line.

    From the error message '"net' is not recognized as an internal.... - it does not complain about the "net" command, it complains about the "net (mind the "-sign leading net). So there is a syntax problem with the quotes in the command line.

    Try,
    Psexec.exe @servers.txt NET.exe LocalGroup Administrators domain\username /add


    btw, the usual way to add a domain user to a local group is by using the 'Restricted groups' policy.

    /Rems

    This posting is provided "AS IS" with no warranties, and confers no rights.

    __________________

    ** Remember to give credit where credit's due **
    and leave Reputation Points for meaningful posts

    Comment


    • #3
      Re: add AD user to local admins group on multiple servers

      quick look of the PRO ...

      I copied the sintax from the web and just made changes to domain user name.
      Then the error message in French "clearly" staying:
      net is not recognized as an internal or external command.
      so I took it from there.

      Thanks you Rems.
      "When you hit a wrong note it's the next note that makes it good or bad". Miles Davis

      Comment

      Working...
      X