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.