Add-DBADbRolemember,dbatools
The below command will create a new user at database level and add that user to the required roles.
cls $UserName='UserNameHere' $InstanceName='InstanceNameHere' New-DbaDbUser -SqlInstance $InstanceName -Database DatbaseNameHere -Username $UserName Add-DbaDbRoleMember -SqlInstance $InstanceName ` -Database DatabaseNameHere ` -Role "db_ddladmin","db_executor","db_datawriter","db_datareader","db_spexec" ` -User $UserName -Verbose
Comments