Forum Discussion

Lee-Martin's avatar
Lee-Martin
Brass Contributor
Jan 16, 2023

Add-PnPTenantTheme - Attempted to perform an unauthorized operation.

I've tried to upload a theme, but I'm geting an Attempted to perform an unauthorized operation

 

I'm an admin on the particular site I'm trying to upload to, so I assumed this would be enough permissions?

 

Do I need other permissions in order to be able to do this task?

 

Thanks

 

 

  • SvenSieverding's avatar
    SvenSieverding
    Bronze Contributor

    Hi Lee-Martin ,

    Add-PnPTenantTheme tries to create a new theme that you can use tenant-wide in all site collections. You need SharePoint Admin permissions and you have to be connected to the admin site to use that command.

    I use a PnP site template to  invoke a custom theme on a single site collection:

    <?xml version="1.0"?>
    <pnp:Provisioning xmlns:pnp="http://schemas.dev.office.com/PnP/2022/09/ProvisioningSchema">
      <pnp:Templates ID="ThemeTemplate">
        <pnp:ProvisioningTemplate ID="ThemeProvisioningTemplate" >
          <pnp:Theme Name="MyColorTheme" IsInverted="false">
            {
            "themePrimary": "#aaaaaa",
            "themeLighterAlt": "#fefcf6",
            "themeLighter": "#fcf3dd",
            "themeLight": "#fae8bf",
            "themeTertiary": "#f4d282",
            "themeSecondary": "#efbe4b",
            "themeDarkAlt": "#d5a32f",
            "themeDark": "#b48a28",
            "themeDarker": "#85661d",
            "neutralLighterAlt": "#f8f8f8",
            "neutralLighter": "#f4f4f4",
            "neutralLight": "#eaeaea",
            "neutralQuaternaryAlt": "#dadada",
            "neutralQuaternary": "#d0d0d0",
            "neutralTertiaryAlt": "#c8c8c8",
            "neutralTertiary": "#a9a9a9",
            "neutralSecondary": "#8d8d8d",
            "neutralPrimaryAlt": "#727272",
            "neutralPrimary": "#020202",
            "neutralDark": "#3a3a3a",
            "black": "#1e1e1e",
            "white": "#ffffff",
            "bodyBackground": "#ffffff",
            "bodyText": "#020202"
            }
          </pnp:Theme>
        </pnp:ProvisioningTemplate>
      </pnp:Templates>
    </pnp:Provisioning>
    Invoke-PnPSiteTemplate .\theme.xml


    But there might be better ways to do so.

    Best Regards,
    Sven

    • Lee-Martin's avatar
      Lee-Martin
      Brass Contributor
      Thanks, I've tried that an am getting the error

      Invoke-PnPSiteTemplate : Cannot contact site at the specified URL https://<myhomesite>.sharepoint.com/<mysite>. There is
      no Web named "/<mysite>/_vti_bin/sites.asmx".
      • SvenSieverding's avatar
        SvenSieverding
        Bronze Contributor

        Hello Lee-Martin,

        Are you connected to the correct url? Like

        https://<myhomesite>.sharepoint.com/sites/<mysite>?

        What happens, if you execute the command "Get-PnPWeb"?
        Do you get the same error?

        Best Regards,
        Sven

Resources