Avatar of arcj1234
arcj1234
 asked on

scripting SQL logins using VB

Hello and thank you for helping me.  I have over 20 SQL servers where I have to grant local backup operator access, create an SQL login account and Grant sa access.  I would like to use a VB or batch script to read the servers from a file to grant the access and create the SQL account.  I am not sure how to proceed with this.  Can you please give some examples or link to where I can find the answer?
VB ScriptMicrosoft SQL ServerMicrosoft SQL Server 2005

Avatar of undefined
Last Comment
Marten Rune

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
ste5an

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Marten Rune

Do you have access to them from SSMS???
If so, why not use a multiquery in SSMS.

in SSMS use "view/registered servers"
in "local Server Groups" rightclick and add a "New Server Group" name it to something good.
now register each of the 20 servers to this Group by rightclick on the Group and choose "New Server Registration"
When they are all in there, rightclick on the Group, and choose "New Query"
This Query will execute against all of the servers, try it out by typing:
Select @@ServerName
and hit enter
Youll see 20 columns, to understand this even simpler
wipe the Query and type:
Select name from sys.databases
hit enter
Now you can see all your databases, and in the first column it's automatically shown on wich server the result came from.

Regards Marten
Marten Rune

arcj1234

Any Feedback?!?
If the solutions are unacceptable, then write that this is the case and the reason. Otherwose you wont get any more proposed solutions.

Regards Marten
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes