Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

SQL Server runs under AD Account SQLAccount1. How to make it run under another account, SQLAccount2? How to do it un Powershell?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted
  1. The GUI way to do this is to go to SQL Server Configuration Manager. Go to the properties of the SQL Server and change the account name on the Log On tab. Click the Browse button.

enter image description here

Than enter the account that you want to SQL Server Log on as. Click Check Names, to make sure the account exists. Than click OK on select user or group and OK on SQL Server Properties.

enter image description here

Than restart.

2.This blog Hey, Scripting Guy! Blog, the author Aaron Nelson - SQLvariant shows how to do this in PowerShell.

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | out-null

$SMOWmiserver = New-Object ('Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer') "WIN7NetBook" #Suck in the server you want

#These just act as some queries about the SQL Services on the machine you specified.
$SMOWmiserver.Services | select name, type, ServiceAccount, DisplayName, Properties, StartMode, StartupParameters | Format-Table

#Same information just pivot the data
$SMOWmiserver.Services | select name, type, ServiceAccount, DisplayName, Properties, StartMode, StartupParameters | Format-List

#Specify the "Name" (from the query above) of the one service whose Service Account you want to change.

$ChangeService=$SMOWmiserver.Services | where {$_.name -eq "MSSQLSERVER"} #Make sure this is what you want changed!

#Check which service you have loaded first

$ChangeService

$UName="DomainName\UserName"

$PWord="YourPassword"

$ChangeService.SetServiceAccount($UName, $PWord)

#Now take a look at it afterwards

$ChangeService
share|improve this answer
1  
That blog post was actually written by guest blogger, Aaron Nelson (dba.stackexchange.com/users/2420/aaron-nelson-sqlvariant) –  Shawn Melton Aug 5 '12 at 2:17
    
Thank you, I'll correct it. –  benRollag Aug 5 '12 at 2:22
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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