-
Notifications
You must be signed in to change notification settings - Fork 395
Description
Reporting an Issue or Missing Feature
Issue when running the command as a SharePoint Administrator only without Site Collection Admin role. The Graph API command to add site permissions should allow this without Site Collection Admin (ref: https://learn.microsoft.com/en-us/graph/api/site-post-permissions?view=graph-rest-1.0&tabs=http)
However the PnP implementation looks up the SiteId from the Graph API which requires Site Collection Administrator role on the associated site
(ref: https://learn.microsoft.com/en-us/graph/api/site-get?view=graph-rest-1.0&tabs=http)
Affected line:
| siteId = Site.GetSiteIdThroughGraph(Connection, AccessToken); |
Note that the above function returns the SiteId, which is also available from (Get-PnPTenantSite ...).SiteId which can be retrieved with the SharePoint Administrator role only.
Expected behavior
This command should be able to be run by users with the SharePoint Administrator role using Delegated permissions.
Actual behavior
VERBOSE: Cmdlet execution started for Grant-PnPAzureADAppSitePermission -Site "<SiteUrl>" -Connection $DevAdminConnection -Permissions Read -AppId "<AppId>" -DisplayName "PnP - Sites.Selected" -Verbose VERBOSE: Using Microsoft Graph to lookup the site Id of the passed in site using -Site
Grant-PnPAzureADAppSitePermission: {"error":{"code":"accessDenied","message":"Access denied","innerError":{"date":"2025-12-19T11:30:50","request-id":"<id>","client-request-id":"<id>"}}}
Steps to reproduce behavior
Run the command on a Site Collection where you are not a Site Collection Admin (e.g. another user's OneDrive site) but are a SharePoint Administrator role.
What is the version of the Cmdlet module you are running?
3.1.0
Which operating system/environment are you running PnP PowerShell on?
- Windows
- Linux
- MacOS
- Azure Cloud Shell
- Azure Functions
- Other : please specify