Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kathyblasco opened this issue Mar 30, 2021 · 12 comments · Fixed by #1324
Closed

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

kathyblasco opened this issue Mar 30, 2021 · 12 comments · Fixed by #1324

Comments

@kathyblasco
Copy link

kathyblasco commented Mar 30, 2021

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

@ghost ghost added the ToTriage label Mar 30, 2021
@ddyett ddyett added Bug - P2 and removed ToTriage labels Mar 31, 2021
@peombwa
Copy link
Member

peombwa commented Mar 31, 2021

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.

@peombwa
Copy link
Member

peombwa commented Mar 31, 2021

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 microsoftgraph/microsoft-graph-devx-api#509.

@kathyblasco
Copy link
Author

kathyblasco commented Apr 1, 2021 via email

@peombwa
Copy link
Member

peombwa commented Apr 1, 2021

@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.

@kathyblasco
Copy link
Author

kathyblasco commented Apr 1, 2021 via email

@lbenkensteinGP
Copy link

lbenkensteinGP commented Jun 24, 2022

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

@peombwa
Copy link
Member

peombwa commented Jun 27, 2022

The command works as expected in v1.10.0:
image

Please note that the API only supports application permissions. See https://docs.microsoft.com/en-us/graph/api/site-list-permissions?view=graph-rest-1.0&tabs=http#permissions.

See https://docs.microsoft.com/en-us/powershell/microsoftgraph/app-only?toc=%2Fgraph%2Ftoc.json&view=graph-powershell-1.0&viewFallbackFrom=graph-rest-1.0&tabs=azure-portal for how to use app-only authentication with the PowerShell SDK.

@teephysicist
Copy link

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

@lbenkensteinGP
Copy link

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

@Asaurdiff-Tillamook
Copy link

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.

@Skaldhor
Copy link

Skaldhor commented Aug 2, 2022

@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.

@tberta
Copy link

tberta commented Oct 10, 2023

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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants