dbatools is a free PowerShell module with over 300 SQL Server administration, best practice and migration commands included.

Please note that documentation and command names may be out of date while we work furiously towards 1.0


Reconfigures service account or updates password of the specified SQL Server service. The service will be restarted in the event of changing the account.




Changes the current service account’s password of the service MSSQL$MYINSTANCE to ‘Qwerty1234’.

$NewPassword = ConvertTo-SecureString ‘Qwerty1234’ -AsPlainText -Force
Update-DbaSqlServiceAccount -ComputerName sql1 -ServiceName ‘MSSQL$MYINSTANCE’ -Password $NewPassword

Requests credentials from the user and configures them as a service account for the SQL Server engine and agent services of the instance sql1\MYINSTANCE.

$cred = Get-Credential
Get-DbaSqlService sql1 -Type Engine,Agent -Instance MYINSTANCE | Update-DbaSqlServiceAccount -ServiceCredential $cred

Configures SQL Server engine and agent services on the machines sql1 and sql2 to run under Network Service system user.

Update-DbaSqlServiceAccount -ComputerName sql1,sql2 -ServiceName ‘MSSQLSERVER’,’SQLSERVERAGENT’ -Username NETWORKSERVICE

Configures SQL Server engine service on the machine sql1 to run under ‘MyDomain\sqluser1’. Will request user to input the account password.

Get-DbaSqlService sql1 -Type Engine -Instance MSSQLSERVER | Update-DbaSqlServiceAccount -Username ‘MyDomain\sqluser1’


This command was created by Kirill Kravtsov. You can find Kirill on Twitter.


From PowerShell, execute Get-Help Update-DbaSqlServiceAccount -Detailed for more information on this function.

Source Code

Want to see the source code? View Update-DbaSqlServiceAccount.ps1 on GitHub

Related commands