question

KathyBlasco-4579 avatar image
0 Votes"
KathyBlasco-4579 asked saldana-msft edited

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

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__AnonymousType48`8) [Get-MgSite_List1], RestException`1
+ 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.



windows-server-powershellmicrosoft-graph-sites-lists
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

MichaelHan-MSFT avatar image
0 Votes"
MichaelHan-MSFT answered

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.



image.png (11.6 KiB)
image.png (65.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

KathyBlasco-4579 avatar image
0 Votes"
KathyBlasco-4579 answered

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!

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.