SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Add a login to multiple SQL Servers

By Vishnu Gupthan,

#######################################################################################################################################
Pre requisites for this script to run.
A.Below files shoule exist
   1. D:\ps\AddUser\AddLoginquery.sql--> Add user SQL script location
   2. D:\ps\AddLogin\SQLServerList.txt --> Text file with the SQL Server connection string details
#######################################################################################################################################
Log file location --> D:\ps\AddLogin\log1.txt
#######################################################################################################################################
D:\ps\AddUser\AddLoginquery.sql should be saved as the .SQL file in the metioned location in the below Format.
--For Windows Login creation
CREATE LOGIN <name of Windows User> FROM WINDOWS; GO 
--For SQL Login creation
CREATE LOGIN <login name> WITH PASSWORD = '<password>' ; GO
#######################################################################################################################################
Once all the  above mentoned scripts , location and files are ready , we are good to go with the execution of the powershell script attached. 
Note: You can very well change the SQL Script to your desired one if you want to perfrom some other operation across multiple SQL Server instances. 

Total article views: 435 | Views in the last 30 days: 18
 
Related Articles
FORUM

restrict windows authentication login

restrict windows authentication login

FORUM

SQL Server Login and Windows Auth

Login, Windows Authentication

FORUM

logins

logins

FORUM

Create Login Script

Error with Create Login Script

FORUM

what is the difference between SQl login and windows login

what is the difference between SQl login and windows login

 
Contribute