• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 436
  • Last Modified:

script to create local groups in a list of servers

Hi Experts,
I am looking for a script to create local groups in a list of servers, i have got the batch script to create these local groups on a single server, but needs to run the script through a list of 100's of servers.

Please let me know how do i do that.
I have been trying this way:

set listsvrs=testusr
for %%i in (%listsvrs%.txt) do (
net localgroup "testuser" /ADD /COMMENT:"test user"
)


but it doesn't run this way and stops at "set listsvrs=testusr" mentioning the syntax of the command is incorrect.

Many Thanks
0
SALinfo
Asked:
SALinfo
3 Solutions
 
GBigACommented:
I am not clear why you are setting that variable to testusr and not using that.
Also, you are looping and your variable is %%i but you are not using it...
Seems to me that what you are trying to do is run that command on 100 diffrent servers, but I dont see how you will manage by running that code on one of them... You need a script that logs on each and run that command.
0
 
SALinfoAuthor Commented:
Yes, i want the script to create local groups and run it as a loop on 100 different servers.
please let me know if you got any thing similar which can do what i am looking for
As mentioned above, i have got the script for creating local groups on a single and is working but i need it for it run and create those local groups on 100 list of servers picking up from servers.txt file.

servers is the list of servers in a text file

set listsvrs=servers
for %%i in (%listsvrs%.txt) do (
net localgroup "testuser" /ADD /COMMENT:"test user"
)
0
 
Seaton007Commented:
Here is some information on a script for creating local users on multiple remote computers:
VBScript to add local accounts on multiple machines
(see the bottom of the last post on that page for the script)

It can probably be easily modified to create local groups instead of local users.
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
SALinfoAuthor Commented:
can someone pls help with the above batch scripting which is a simple way.


thx
0
 
David Johnson, CD, MVPOwnerCommented:
you will need a 3rd party tool called psexec from sysinternals
http://www.microsoft.com/sysinternals


set listsvrs=servers
psexec @%listsrvrs%.txt -s net localgroup "testuser" /ADD /COMMENT:"test user"
0
 
yo_beeDirector of ITCommented:
I see that you tagged this for both 2003 and 2008.
If you RSAT installed on your 2008 server you can use GPP (Group Policy Preferences)

Computer Config > Preferences > Control Panel Setting > Local Users and Group > Right click and select New Group.

http://www.grouppolicy.biz/2010/01/how-to-use-group-policy-preferences-to-secure-local-administrator-groups/
0
 
yo_beeDirector of ITCommented:
Note to my previous  post

Target only the servers you want to add the group to
0
 
Dale HarrisCommented:
You can also do this very easily with a Powershell Script:
http://www.petri.co.il/create-local-accounts-with-powershell.htm

-Dale Harris
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now