Changing SQL Server service account

We will see how to change SQL Server accounts in this recipe.

Getting ready

For this recipe, you will need to create another Windows/Domain account that you can use to change the service account to.

In this recipe, we will change the service account for SQLSERVERAGENT from QUERYWORKS\sqlservice to QUERYWORKS\sqlagent, which are available in the Virtual Machine (VM) created in Appendix B, Creating a SQL Server VM if you've created the same VM. If you are using a different environment, you must substitute these with accounts that already exist in your system.

How to do it...

Let's explore the code required to change a SQL Server service account:

  1. Open PowerShell ISE as an administrator.
  2. Import the SQLPS module and create ...

Get SQL Server 2014 with PowerShell v5 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.