Create SQL Login with Powershell and T-SQL
If you ever have the need to create a number of logins and users for a specific database(s) programmatically, then the following scripts may be of use to you. The first script leverages the strength of Powershell and can be extended for example to pull a number of usernames and passwords from a file and then use these to create the necessary logins. For our purposes today, I’ve decided to use a hardcoded username and password but it is nice to know that Powershell can do much more. The script is attached below: #import SQL Server module Import-Module …[read more]