Created
February 15, 2011 02:59
-
-
Save jstangroome/827023 to your computer and use it in GitHub Desktop.
Grant a role to a user on a Reporting Services item
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment