Search code examples
batch-filecommand-linescriptingpsexec

PSEXEC: Add User to Remote Desktop Users Group on Multiple Computers


I successfully wrote a script to add a user to the Remote Desktop Users group on one computer through PSEXEC.

psexec \\pc-%cn% NET LOCALGROUP "Remote Desktop Users" domain\%fn%.%ln% /ADD

This line of code is part of a larger script which receives the variables (%cn%, %fn%, and %ln%) as inputs before this part of the script runs.

Now I want to add a user to multiple computers through looping through a txt, bat or cmd file?

I have searched on Google and thru this website and have not found a satisfactory solution.

Thanks for any help I can get.


Solution

  • psexec @myfile.txt -e -d NET LOCALGROUP "Remote Desktop Users" domain\%fn%.%ln% /ADD
    

    This worked on multiple computers