Share via

Error "Get-SPOTheme : Unknown Error"

john john 1,031 Reputation points
2021-12-07T13:15:00.99+00:00

We need to modify some color codes for the built-in Red theme:-

155666-image.png

So i tried running this command to get the JSON of the Red theme, but i got error:-

PS C:\WINDOWS\system32> Connect-SPOService -url https://***-admin.sharepoint.com   
PS C:\WINDOWS\system32> Get-SPOTheme -Name "Red" | ConvertTo-Json Get-SPOTheme  
: Unknown Error At line:1 char:1  
+ Get-SPOTheme -Name "Red" | ConvertTo-Json  
+ ~~~~~~~~~~~~~~~~~~~~~~~~  
    + CategoryInfo          : NotSpecified: (:) [Get-SPOTheme], ServerException  
    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.GetSPOTheme  

Also when i tried to get all the themses, i got nothing:-

PS C:\WINDOWS\system32> Get-SPOTheme  
PS C:\WINDOWS\system32>   

any advice ?

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments

1 answer

Sort by: Most helpful
  1. JoyZ 18,131 Reputation points
    2021-12-08T02:16:16.29+00:00

    @john john ,

    Until you add a custom theme via Add-SPOTheme, there will be no output.

    And we can customize default theme in SharePoint UI, however unable to get the JSON of the built-in theme.

    As a workaround, use the Theme Generator tool to build a custom theme. It provides an interactive UI for selecting theme colors, and automatically generates the JSON, SASS, and PowerShell definitions for your custom theme.

    More inforamtion for your reference:

    https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/site-theming/sharepoint-site-theming-json-schema

    -------------------------------------Update----------------------------------------------

    Use following code to define a dictionary in PowerShell for the Red theme's color palette for your reference:

    $themepalette = @{  
    "themePrimary" = "#d13438";       
    "themeLighterAlt" = "#fdf5f5";   
    "themeLighter" = "#faebeb";  
    "themeLight" = "#f6d6d8";     
    "themeTertiary" = "#ecaaac";  
    "themeSecondary" = "#d6494d";   
    "themeDarkAlt" = "#c02b30";   
    "themeDark" = "#952226";    
    "themeDarker" = "#751b1e";   
    "neutralLighterAlt" = "#f8f8f8";     
    "neutralLighter" = "#f4f4f4";      
    "neutralLight" = "#eaeaea";      
    "neutralQuaternaryAlt" = "#dadada";  
    "neutralQuaternary" = "#d0d0d0";   
    "neutralTertiaryAlt"= "#c8c8c8";   
    "neutralTertiary" = "#a6a6a6";  
    "neutralSecondaryAlt" = "#767676";  
    "neutralSecondary" = "#666666";  
    "neutralPrimary" = "#333";  
    "neutralPrimaryAlt" = "#3c3c3c";  
    "neutralDark" = "#212121";   
    "black" = "#000000";  
    "white" = "#fff";   
    "primaryBackground" = "#fff";   
    "primaryText" = "#333"  
    }  
    
    Add-SPOTheme -Identity "Julie Custom" -Palette $themepalette -IsInverted $false -Overwrite  
    Get-SPOTheme -Name "Julie Custom" | ConvertTo-Json  
    

    Result:

    156189-image.png


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.