本文介绍了WMI ManagedComputer SetServiceAccount给人"设置服务帐户失败"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图自动执行SQL + SSRS服务器安装(MS SQL 2012前preSS)的安装后的配置 - 我认为这是或多或少的。但是,这是我首次涉足PowerShell中,我从来没有配置,甚至使用MS SQL之前。我的服务器是Windows 2008 R2的虚拟机,在那里我是管理员和SQL服务器安装在本地(非群集)。我使用PowerShell的2.0版运行下面的代码片段(如管理员):

I'm trying to automate the post-install configuration of an SQL+SSRS server installation (MS SQL 2012 Express) -- I think it's more or less this. However, this is my first foray into Powershell, and I have never before configured or even used MS SQL. My server is a Windows 2008 R2 virtual machine, where I'm an admin, and the SQL server is installed locally (not clustered). I'm using Powershell v2.0 to run the following snippet (as an admin):

Write-Output("- Setting service account ...")
Write-Output("  - Loading assembly ...")
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SqlWmiManagement") | out-null
Write-Output("  - Loading server ...")
$mc = New-Object -TypeName Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer "$hostname"
Write-Output("  - Loading service ...")
#$service = $mc.Services | Where {$_.Name -eq "MSSQL`$$sqlInstanceName"}
$service = $mc.Services | Where {$_.Name -eq "ReportServer`$$sqlInstanceName"}
Write-Output("  - Changing service account credentials ...")
$service.SetServiceAccount("$hostname\sa", "$sapwd")
Write-Output("  - Commit ...")
$service.Alter()
Write-Output("- OK.")

之间的更改服务帐户凭据和提交,我的code失败,此消息:

Between "Changing service account credentials" and "Commit", my code fails with this message:

Exception calling "SetServiceAccount" with "2" argument(s):
"Set service account failed."

$ SAPWD 是SQL Server的安装过程中提供的密码。我从来没有要求相应的用户名,但有人告诉我,有一个sa用户是隐含的。我没有在本地机器上使用该名称的Windows用户;我不能确定什么样的用户在(新安装)SQL服务器的定义。

The $sapwd is the password given during the SQL server installation. I'm never asked for a corresponding user name, but am told that there is an "SA" user is implied. I don't have a Windows user by that name on the local machine; I'm unsure of what users are defined in a (newly-installed) SQL server.

在这里,我的目标就是使用GUI设置了服务帐户为使用内置帐户:网络服务相当于,在code段是基于这个 code。 This帖子,不是完全无关,但(一)它没有回答,和(b)我不使用群集。

My goal here is the equivalent of using the GUI to set the "Service Account" to "Use built-in account: Network Service", The code snippet is based on this code. This post is not totally unrelated, but (a) it's not answered, and (b) I don't use clustering.

许多人都有过这样的问题,但似乎并没有是为我工作的任何固体的答案。我怎么能连的查找有关的信息的这个错误是什么意思,以及如何解决它?

Many others have had this problem, but there don't seem to be any solid answers that work for me. How can I even find information about what this error means, and how to work around it?

奖金

我还需要改变Web服务URL和报表管理器URL;如果你对任何提示如何做到这一点,你会救我一堆小时。

I'll also need to change the "Web Service URL" and the "Report Manager URL"; if you've any tips on how to do that you'll save me a bunch of hours.

推荐答案

SA 数据库的用户(内嵌数据库管理员帐户)不是的窗口的用户。对于运行服务,你需要一个Windows用户帐户。通常是您为运行服务(具有所需权限/权限)或类似内置的默认账户之一NT AUTHORITY \\ Network服务或<$ C $创建了一个专门的帐户C> NT AUTHORITY \\ Local服务。

sa is a database user (the builtin database administrator account), not a Windows user. For running a service you need a Windows user account. Usually either a dedicated account you created for running the service (with the required permissions/privileges) or one of the builtin default accounts like NT AUTHORITY\Network Service or NT AUTHORITY\Local Service.

使用内置帐户之一时,传递一个空字符串作为第二个参数,因为他们没有一个密码:

Pass an empty string as the second parameter when using one of the builtin accounts, since they don't have a password:

$service.SetServiceAccount('NT AUTHORITY\Network Service', '')

随着中说,通常你应该指定的运行方式在安装过程中占据了数据库服务,所以不应该有一个需要事后改变它。

With that said, normally you should have specified the runas account for the database service during the installation, so there shouldn't be a need for changing it afterwards.

这篇关于WMI ManagedComputer SetServiceAccount给人&QUOT;设置服务帐户失败&QUOT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 05:47