logo
search
Permission & Access Issues

Fix Attempted to Perform an Unauthorized Operation in Invoke-PnPTenantTemplate

Maira MehtabMaira Mehtab Sep 22, 2026 868 views

Question details

The user needs to resolve an unauthorized operation error that occurs when executing the Invoke-PnPTenantTemplate cmdlet in PnP PowerShell.

Product
SharePoint Online PnP PowerShell
Device & OS
not provided
Scenario
Applying a tenant template to SharePoint Online using the Invoke-PnPTenantTemplate command.
Observed behavior
The system throws an 'Attempted to perform an unauthorized operation' error and fails to apply the tenant template.
Before you start

Ensure you have Global Administrator or SharePoint Administrator privileges in your Microsoft 365 tenant before executing tenant-level PnP PowerShell scripts. Verify that you are running the latest version of the PnP PowerShell module.

Solution 1Recommended

Verify Entra ID App Permissions and Admin Consent

Use this solution to ensure your Azure AD (Entra ID) application has the correct API permissions granted and consented to for tenant-level provisioning.

Tenant-level operations in PnP PowerShell typically require specific Microsoft Graph and SharePoint permissions configured via an Entra ID app registration.

1
Access Microsoft Entra Admin Center

Log in to the Microsoft Entra admin center and navigate to 'App registrations' to locate the custom app used for your PnP PowerShell connection.

2
Check API Permissions

Click on 'API permissions' and verify that you have added the required SharePoint and Microsoft Graph permissions for tenant operations (e.g., Sites.FullControl.All).

3
Grant Admin Consent

Click the 'Grant admin consent for [Your Tenant]' button to ensure all requested permissions are authorized at the tenant level.

4
Reconnect PnP PowerShell

Run the Connect-PnPOnline cmdlet again, specifying your ClientId, Tenant, and Certificate/Thumbprint to re-authenticate with the newly granted permissions.

Authentication Method: Using a certificate-based authentication method is highly recommended for unattended tenant-level PowerShell scripts.
Free Microsoft Office alternative

Enhance Your Daily Productivity with WPS Office

While SharePoint and PowerShell require complex administrative troubleshooting, your daily document management shouldn't. WPS Office provides a free, lightweight, and powerful alternative to Microsoft Office, allowing you to easily handle standard documents, spreadsheets, and presentations without subscription hassles.

  1. 1. Download the Installer: Visit the official WPS Office website and click the free download button for your operating system.
  2. 2. Install the Software: Run the downloaded installer and follow the simple on-screen instructions to complete the setup.
  3. 3. Open Your Files: Launch WPS Office and directly open your existing Word, Excel, or PowerPoint files to start working immediately.
Fully compatible with Microsoft Office formats including DOCX, XLSX, and PPTX.Free, lightweight, and incredibly fast to install on any device.Familiar user interface ensuring a seamless migration with zero learning curve.Built-in PDF toolkit and AI features to boost your document workflow.
microsoft office alternative - wps office

Frequently Asked Questions

Why does Invoke-PnPTenantTemplate require special administrative permissions?

This command modifies resources at the tenant level, which can include creating site collections, applying global themes, or modifying security settings. These actions strictly require elevated privileges such as the SharePoint Administrator or Global Administrator roles.

Can I use interactive login with Invoke-PnPTenantTemplate?

While interactive login can work for standard site operations, tenant-level templates and provisioning heavily rely on Azure AD (Entra ID) app registrations using certificate-based authentication to ensure secure and authorized access.

How do I update my PnP PowerShell module?

Open a PowerShell window as an Administrator and run 'Update-Module -Name PnP.PowerShell' to install the latest version, which may contain critical bug fixes for unauthorized operation errors.