且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

更改MS SQL报告服务帐户内置的"网络服务与QUOT;

更新时间:2022-05-29 19:05:07

因此​​,原来居然有一些非常简单的code做到这一点。我的同事发现,由奥术魔法,我不知道。

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.

这里的code:

# 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.