1

I would like to have a report of which sites a specific group or user has on all the SharePoint sites.

I have this group called SPGroup and I want to see on which sites this group has permissions on, including all subsites.

Can this be done by using Client context?

I can't find anything where it explains how to do this.

2 Answers 2

0

If you just want to find WHERE this group has permissions at SITE COLLECTION level, but not WHAT permissions and NOT subsites, then use SharePoint Online Management Shell and:

Get-SPOUser -Site

e.g.

   $sites=(get-SPOSite).Url
  foreach($site in $sites){ foreach($user in (get-spouser -site $site)){ if($user.DisplayName -eq "SPGroup") {write-host $site}}}
2
  • I need to check permissions on the subsite level. Thanks anyway
    – ArKersten
    Jul 13, 2016 at 7:25
  • If I find the time, I'll write CSOM for the subsites and change the answer.
    – grisha
    Jul 13, 2016 at 8:38
0

This exists on the RoleAssignment.Groups property.

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spweb.associatedgroups.aspx

# Note -- I have a function for creating the context.
$Ctx = Get-Context $Credentials $SubSiteURL
$Ctx.Load($Ctx.Web.RoleAssignments.Groups)
$Ctx.ExecuteQuery()
ForEach($Group in $Ctx.Web.RoleAssignments.Groups)
{
    $Ctx.Load($Group)
    $Ctx.ExecuteQuery()
    Write-Output ("{0} -> {1} -> {2}" -f $Group.Id, $Group.Title, $Group.Description)
}

Output:

3 -> Excel Services Viewers -> Members of this group can view pages, list items, and documents.  If the document has a
 server rendering available, they can only view the document using the server rendering.
7 -> IT TEST AREA Members -> 
5 -> IT TEST AREA Owners -> 
6 -> IT TEST AREA Visitors -> 
21 -> SharingLinks....OrganizationEdit.... -> This group is for OrganizationEdit sharing links on item 'DocURL'
26 -> TESt Members -> Use this group to grant people contribute permissions to the SharePoint site: TESt
27 -> TESt Visitors -> Use this group to grant people read permissions to the SharePoint site: TESt

Just write something to iterate through all items under the root web, like this.

Function Get-SubSites($Credentials, $SiteURL)
{
    # Check if this is the parent web or not
    $Context = Get-Context $Credentials $SiteURL
    $Context.Load($Context.Web.Webs)
    $Context.ExecuteQuery()
    # Collect whatever you want and append it to an array
    $Report += $Context.Web.Url
    ForEach($Web in $Context.Web.Webs)
    {
        Get-SubSites $Credentials $Web.Url
    }
    $Context.Dispose()
}
$Script:Report = @()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.