Has anyone been able to retrieve site permissions using Get-MgSite?

Kathy Blasco 101 Reputation points
2021-03-29T21:26:01.577+00:00

I am using PowerShell graph statements.

Connecting with:

Connect-MgGraph -ClientID $myClientId -TenantId $myTenantId -CertificateThumbprint $myThumbprint

My Azure application has Sites.FulControl.All and has been granted by the admin.

Then executing:

$sites = @(Get-MgSite -Property Permissions -All |Where WebUrl -eq $myWebUrl)

$sites[0] has the specific site information associated with $myWebUrl but there is nothing returned in $sites[0].permissions.

I also tried to use:

$sites = @(Get-MgSite -ExpandProperty Permissions -All |Where WebUrl -eq $myWebUrl) but get the following error:

And get Error:

Get-MgSite : The requested expand is not supported for this endpoint. Property: 'permissions'
At line:1 char:1

  • $sites = @(Get-MgSite -ExpandProperty Permissions -All |Where WebUrl ...
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  • CategoryInfo : InvalidOperation: ({ Top = 100, Sk...stem.String[] }:<>f__AnonymousType488) [Get-MgSite_List1], RestException1
  • FullyQualifiedErrorId : invalidRequest,Microsoft.Graph.PowerShell.Cmdlets.GetMgSite_List1

I have also tried to get permissions for the subsites using:

$subSites = @(Get-MgSubSite -ExpandProperty Permissions -SiteId $sites[0].Id -All)

AND

$subSites = @(Get-MgSubSite -Property Permissions -SiteId $sites[0].Id -All)

No error but no data in $subSites.permissions either.

Any suggestions? I also need to get permissions at the library level and don't see permissions as a property for Get-MgSiteDrive or Get-MgSiteList.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,521 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,355 questions
0 comments No comments
{count} votes

Accepted answer
  1. MichaelHan-MSFT 18,016 Reputation points
    2021-03-30T08:02:50.457+00:00

    Hi anonymous user-4579 ,

    Per my test, I got the same result as yours on my end. As the below screenshot shows:

    82723-image.png

    I also tried to format the $sites to retrieve all the properties in it. And there is no data for the property Permissions.

    82629-image.png

    So I think currently we can not list the permissions of SharePoint sites through Graph powershell. The Microsoft Graph PowerShell SDK may be incomplete. And you could submit the feedback here: https://github.com/microsoftgraph/msgraph-sdk-powershell/issues


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Kathy Blasco 101 Reputation points
    2021-03-30T15:08:25.323+00:00

    Thanks @MichaelHan-MSFT !
    This is the first time I have submitted an entry for an issue. It is: https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/600

    If you have any suggested changes to that entry please advise!

    0 comments No comments