Rob Sewell shows how to use dbatools to create test user accounts quickly:
Of course we can use any source for our users – a database, an excel file, Active Directory or even just type them in.
We can use the Add-SQLLogin command from the sqlserver module to add our users as SQL Logins, but at present we cannot add them as database users and assign them to a role.
Rob includes a demo script as well, thereby making it even easier.