本文介绍了使用 Powershell 在 Reporting Services 中设置用户权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我之所以这么问是因为我对 Powershell 不熟悉.
I'm asking this because i'm a n00b when it comes to Powershell.
我如何使用 Powershell 将特定域用户或组添加到 SSRS2005 中的特定报告角色(例如 Content Manager 或 Browser 角色)?有没有简单的一两行脚本来实现?
How do i use Powershell to add a particular domain user or group to a specific reporting role in SSRS2005 (say the Content Manager or Browser role)? Is there a simple one or two line script to achieve it?
谢谢!
推荐答案
抱歉,这不是一两行,但您可以轻松地将以下示例代码包装成一个可重用的函数:
Sorry, it isn't just one or two lines but you could easily wrap the following sample code into a reusable function:
$ReportServerUri = 'http://myreportserver/ReportServer/ReportService2005.asmx'
$InheritParent = $true
$ItemPath = '/SomeReportFolder'
$GroupUserName = 'MYDOMAIN\SomeUser'
$RoleName = 'SomeReportServerRoleToGrant'
$Proxy = New-WebServiceProxy -Uri $ReportServerUri -Namespace SSRS.ReportingService2005
$Policies = $Proxy.GetPolicies($ItemPath, [ref]$InheritParent)
$Policy = $Policies |
Where-Object { $_.GroupUserName -eq $GroupUserName } |
Select-Object -First 1
if (-not $Policy) {
$Policy = New-Object -TypeName SSRS.ReportingService2005.Policy
$Policy.GroupUserName = $GroupUserName
$Policy.Roles = @()
$Policies += $Policy
}
$Role = $Policy.Roles |
Where-Object { $_.Name -eq $RoleName } |
Select-Object -First 1
if (-not $Role) {
$Role = New-Object -TypeName SSRS.ReportingService2005.Role
$Role.Name = $RoleName
$Policy.Roles += $Role
}
$Proxy.SetPolicies($ItemPath, $Policies)
这篇关于使用 Powershell 在 Reporting Services 中设置用户权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!