I'm asking this because i'm a n00b when it comes to Powershell.
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?
Thanks!
Note: this is definately programming related (not server admin), but i am also going to ask this on SF.
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)