-
Notifications
You must be signed in to change notification settings - Fork 392
Description
Reporting an Issue or Missing Feature
The Set-PnPPropertyBagValue command is classified as an AdminCmdlet regardless of how it is used, which causes it to attempt a connection to the SharePoint Online Admin Center even when a tenant admin URL is not specified.
Relevant source code:
| public class SetPropertyBagValue : PnPSharePointOnlineAdminCmdlet |
| // No explicit SharePoint Online Admin Center URL has been provided in the connect, try to guess it using the default <tenant>-admin.sharepoint.<tld> syntax |
| AdminContext = Connection.CloneContext(tenantAdminUrl); |
Expected behavior
The command should be permitted as a non-admin Cmdlet when it targets a specific site and the AllowWebPropertyBagUpdateWhenDenyAddAndCustomizePagesIsEnabled setting is enabled for the tenant.
References:
Actual behavior
The command fails with the following error when trying to update property bag values on a site using a service principal with FullControl permission for the site but lacking permission at the tenant level:
Unable to connect to the SharePoint Online Admin Center at 'https://MYTENANT-admin.sharepoint.com'/ to run this cmdlet. If this URL is incorrect for your tenant, you can pass in the correct Admin Center URL using Connect-PnPOnline -TenantAdminUrl. If you are using Privileged Identity Management (PIM) on your tenant, please ensure you have activated at least the SharePoint Administrator role and allowed some time for it to activate. Error message: Attempted to perform an unauthorized operation.
Steps to reproduce behavior
Run the following command while connected with an account or service principal that does not have tenant admin permissions:
Set-PnPPropertyBagValue -Key "MyKey" -Value "MyValue" -Connection $PnPConnectionWhat is the version of the Cmdlet module you are running?
This issue is present in all versions tested, including up to nightly-3.1.196.