Skip to content

Get-MgSite and Get-MgSubSite need to return the Permissions property #600

Closed

Description

@kathyblasco

Permissions is a propery in both Get-MgSite and Get-MgSubSite but no data is returned for Permssions. Tried both commands using '-ExpandProperty' and '-Property' and there is still no data in the Permissions Property. I also need Permissions returned for Libraries, Files, and Folders.

See: https://docs.microsoft.com/en-us/answers/questions/336355/has-anyone-been-able-to-retrieve-site-permissions.html

Maybe what is needed is to develop the Graph Permissions module as described by: https://docs.microsoft.com/en-us/graph/api/site-list-permissions?view=graph-rest-1.0&tabs=http

Are there any plans to provide SharePoint permissions at any level in upcoming versions?
AB#8791

Activity

  1. peombwa commented on Mar 31, 2021

    @peombwa
    Member

    Thanks for opening this bug.

    I can indeed confirm that the SDK is missing Get-MgSitePermission command that should call /sites/{sitesId}/permissions. We need to update our modules mapping to cover this. This should be available in upcoming versions.

  2. added this to the 1.5.0 milestone on Mar 31, 2021
  3. peombwa commented on Mar 31, 2021

    @peombwa
    Member

    For driveItems, we will need to wait for drives/driveItem/{driveItem-id}/permissions to be added the OpenAPI document that this SDK is generated from. This can be tracked here https://github.com/microsoftgraph/microsoft-graph-devx-api/issues/509.

  4. kathyblasco commented on Apr 1, 2021

    @kathyblasco
    Author
  5. peombwa commented on Apr 1, 2021

    @peombwa
    Member

    Kathy B (@kathyblasco), as a workaround, you could use Invoke-MgGraphRequest to list site and driveItem permissions like this:

    # Authenticate as usual.
    Connect-MgGraph
    
    # Get site permissions
    Invoke-MgGraphRequest -Uri "v1.0/sites/$SiteId/permissions"
    
    # Get driveItem permissions
    Invoke-MgGraphRequest -Uri "v1.0/drives/$DriveId/items/$DriveItemId/permissions"

    Invoke-MgGraphRequest is a command that we recently added to the SDK for making arbitrary requests to Graph.

  6. kathyblasco commented on Apr 1, 2021

    @kathyblasco
    Author
  7. removed this from the Backlog milestone on May 27, 2022
  8. lbenkensteinGP commented on Jun 24, 2022

    @lbenkensteinGP

    I updated Microsoft.Graph to 1.10.0 but permissions output are still empty after running Get-MgSite -Property Permissions -SiteId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx or Get-MgSitePermission -SiteId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx.

    PS C:\Windows\system32> Get-Module

    ModuleType Version Name
    Script 1.10.0 Microsoft.Graph.Authentication
    Script 1.10.0 Microsoft.Graph.Sites

  9. peombwa commented on Jun 27, 2022

    @peombwa
    Member
  10. matthijstuenter commented on Jul 19, 2022

    @matthijstuenter

    Hello, I am running into the same issue even after updating to v1.10.0.
    I have connect using app only authentication with the Sites.Fullcontrol.All permission:
    Get-MGcontext
    The Microsoft.Graph.Sites module has version 1.10.0:
    Get-module MGgraph
    Running get-mgsite -siteid root, the permissions are still empty:
    Get-MGsite
    Running get-mgsitepermission -siteid root permissions are also empty:
    Get-MgsitePermission

  11. lbenkensteinGP commented on Jul 20, 2022

    @lbenkensteinGP

    Am I doing something wrong?

    I tested again, here are all the steps I did:

    1. Created a new SharePoint site, site id: "2fb9..."

    2. Created a new App Registration: "app-CD..."

    3. In "app-CD..." API Permissions I added Application permission for SharePoint "sites.selected".
      image

    4. Successfully granted write permissions for "app-CD..." service principal in the SharePoint site id "2fb9..."
      image

    5. Connected to Microsoft Graph with scope Sites.FullControl.All and checked module version.
      image

    6. Ran Get-Mgsite and Get-MgSitePermission for the SharePoint side id "2fb9..." and it does not show that the "app-CD..." has write permissions on the the site.
      image
      image

  12. Asaurdiff-Tillamook commented on Aug 1, 2022

    @Asaurdiff-Tillamook

    I am not sure why this issue was closed. This is still not resolved. Generally, we don't need permissions to the Root site. WE need permissions to the sites we have created. The Owner/Member/Visitor groups of each individual site. I understand if the sub library or broken inheritance is taken away, but this top level permissions should be seen.
    I am currently on Module Version 1.9.3 and this is still not showing up. Whether i look under Get-MGSite or Get-MGSitePermissions. If this was resolved please tell me how this can be addressed. currently:
    Get-mgsite -All | Where {$.WebUrl -eq } | Get-MgSitePermission -siteId $.Id

    Nor taking the Site ID as a variable or direct. The permissions still don't appear.

  13. Skaldhor commented on Aug 2, 2022

    @Skaldhor

    Peter Ombwa (@peombwa) Please reopen this issue.
    Just like @teephysicist I'm receiving the same output.
    App-only auth with Sites.Fullcontrol.All permission is used, site can be found, Get-MgSitePermission returns nothing, also no error.
    Invoke-MgGraphRequest -Uri "v1.0/sites/$SiteId/permissions" also returns an empty value.

  14. tberta commented on Oct 10, 2023

    @tberta

    The simplest and clearer method I've found to show the existing permissions is by using ToJsonString() method:
    $Perm = Get-MgSitePermission -SiteId $siteId
    $Perm.ToJsonString()
    roles (read or write) are missing here. To get them, query with the PermissionId. I only have permission for 1 application. I suppose you need to adjust the $Perm index if several are defined:
    (Get-MgSitePermission -SiteId $siteId -PermissionId $perm.Id).ToJsonString()

    {
      "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#sites($SiteId)/permissions/$entity"
    ,
      "id": "aTowaS.....MxNzcw",
      "grantedToIdentities": [
        {
      "grantedToIdentities": [
        {
          "application": {
            "displayName": "MyAppName",
            "id": "abcd123-dead-beaf-dead-abcd123"
          }
        }
      ],
      "grantedToIdentitiesV2": [
        {
          "application": {
            "displayName": "MyAppName",
            "id": "abcd123-dead-beaf-dead-abcd123"
          }
        }
      ],
      "roles": [ "read" ]
    }
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions