将MS SQL Reporting服务帐户更改为内置的“网络服务” [英] Change MS SQL Reporting service account to built-in "Network Service"

查看:239
本文介绍了将MS SQL Reporting服务帐户更改为内置的“网络服务”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我刚刚安装了MS SQL Server 2012 Express时,Reporting Services配置管理器的服务帐户页面显示我不是使用内置帐户,而是其他帐户(并且所使用的帐户是 NT Service \ReportServer $< MyServerName> )。

When I have just installed MS SQL Server 2012 Express, then the Reporting Services Configuration Manager's "Service Account" page states that I'm not using a "built-in account" but rather "another account" (and that the used account is NT Service\ReportServer$<MyServerName>). My installation script states that I need to change this to the situation pictured below.

如果我手动打开Reporting Services配置管理器GUI并选择内置选项,然后关闭并重新打开它,该选项仍然设置。但是,如果我使用Powershell调用 SetServiceAccount()(从 Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.Service )设置特定帐户,则使用另一个帐户选项在GUI中保持设置。这是我想要避免。

If I manually open the Reporting Services Configuration Manager GUI and select the "Built-in" option, then close and re-open it, that option is still set. However, if I use Powershell to call SetServiceAccount() (from Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer.Service) to set a specific account, then the "Use another account" option remains set in the GUI. This is what I want to avoid.

挑战:如何以编程方式(通过Powershell或我可以从PS调用)此选项(以及指定给定的帐户,除非我可以依赖网络服务作为默认值)?

The challenge: How can I programmatically (via Powershell, or something I can call from PS) toggle this option (as well as specify a given account, unless I can rely on "Network Service" being the default)?

推荐答案

因此,事实证明有一些非常简单的代码来做到这一点。我的同事发现了,我不知道的奥术魔法。

So it turns out there is actually some very simple code to do this. My coworker found it, by which arcane magic I do not know.

这里的代码:

# Init
$ns = "root\Microsoft\SqlServer\ReportServer\RS_$sqlInstanceName\v11\Admin"
$RSObject = Get-WmiObject -class "MSReportServer_ConfigurationSetting" -namespace "$ns"
# Set service account
$builtInServiceAccount = "Builtin\NetworkService"
$useBuiltInServiceAccount = $true
$RSObject.SetWindowsServiceIdentity($useBuiltInServiceAccount, $builtInServiceAccount, "") | out-null
# Set virtual directory URLs
$HTTPport = 80
$RSObject.RemoveURL("ReportServerWebService", "http://+:$HTTPport", 1033) | out-null
$RSObject.RemoveURL("ReportManager", "http://+:$HTTPport", 1033) | out-null
$RSObject.SetVirtualDirectory("ReportServerWebService", "ReportServer", 1033) | out-null
$RSObject.SetVirtualDirectory("ReportManager", "Reports", 1033) | out-null
$RSObject.ReserveURL("ReportServerWebService", "http://+:$HTTPport", 1033) | out-null
$RSObject.ReserveURL("ReportManager", "http://+:$HTTPport", 1033) | out-null
# Restart service
$serviceName = $RSObject.ServiceName
Restart-Service -Name $serviceName -Force

全部完成。很简单。我真的不想考虑我在这浪费了多少心跳。

All done. So simple. I really don't want to think about how many heartbeats of my life I've wasted on this.

这篇关于将MS SQL Reporting服务帐户更改为内置的“网络服务”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆