I want a power shell script to

  1. Create login
  2. Grant database access
  3. remove Database access

Process will be:

Connect to SQL Server(Instance) -> Check the Database in that server -> Connect to Database -> Create a new login -> Create new user -> Grant new user access to database.

closed as off-topic by sp_BlitzErik, John Eisbrener, MDCCL, McNets, swasheck Sep 19 '17 at 15:44

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – sp_BlitzErik, John Eisbrener, MDCCL, McNets, swasheck
If this question can be reworded to fit the rules in the help center, please edit the question.

  • This is what - you ask for help? or ordering us to create the script for you? – George K Sep 19 '17 at 13:57
  • 8
    You'll probably get a better answer if you post some of the code you've already got written along with where you're stuck. – sp_BlitzErik Sep 19 '17 at 13:57

Have you checked out DBATools yet?

Database permissions

Logins

Not the answer you're looking for? Browse other questions tagged or ask your own question.