Skip to content

Instantly share code, notes, and snippets.

@dev-kperera
Created April 2, 2019 18:13
Show Gist options
  • Save dev-kperera/7f90dcc839dabc9b95436c4b36e86600 to your computer and use it in GitHub Desktop.
Save dev-kperera/7f90dcc839dabc9b95436c4b36e86600 to your computer and use it in GitHub Desktop.
SharePoint site owners have new options for applying custom styles and colors to sites that make it easier to define and manage themes across site collections
# Commands to connect SharePoint Online
$adminUPN="[email protected]"
$orgName= Read-Host -Prompt 'Name of your Office 365 organization, example: contoso'
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential
# Verify SharePont Online Management Shell
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
#Get all available
Get-SPOTheme
#Get specific theme
Get-SPOTheme -Name "Custom Cyan" | ConvertTo-Json
#Queries the current SPOHideDefaultThemes setting
Get-SPOHideDefaultThemes
# Add new theme
$themepalette = @{
"themePrimary" = "#00ffff";
"themeLighterAlt" = "#f3fcfc";
"themeLighter" = "#daffff";
"themeLight" = "#affefe";
"themeTertiary" = "#76ffff";
"themeSecondary" = "#39ffff";
"themeDarkAlt" = "#00c4c4";
"themeDark" = "#009090";
"themeDarker" = "#005252";
"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 "Custom Theme Name" -Palette $themepalette -IsInverted $false
# Remove theme from gallery
Remove-SPOTheme -Name "Custom Theme Name"
<#
References:
Theme generator
https://developer.microsoft.com/en-us/fabric#/styles/themegenerator
Custom theming documentation
https://support.office.com/en-us/article/Change-the-look-of-your-SharePoint-site-06bbadc3-6b04-4a60-9d14-894f6a170818
#>
# Verify SharePont Online Management Shell
Get-Module -Name Microsoft.Online.SharePoint.PowerShell -ListAvailable | Select Name,Version
# To verify your setup
# If the cmdlet runs and returns False with no errors, as shown in the following example, you're ready to proceed.
Get-SPOHideDefaultThemes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment