|
| 1 | +--- |
| 2 | +title: SharePoint site theming - PowerShell cmdlets |
| 3 | +description: SharePoint tenant administrators can use PowerShell cmdlets to create, retrieve, and remove site themes. Developers can use the SharePoint REST API to handle theme management tasks. |
| 4 | +ms.date: 03/22/2018 |
| 5 | +--- |
| 6 | + |
1 | 7 | # SharePoint site theming: PowerShell cmdlets
|
2 | 8 |
|
3 |
| -SharePoint tenant administrators can use PowerShell cmdlets to create, retrieve, and remove site themes. Developers can also use the SharePoint [REST API](sharepoint-site-theming-rest-api.md) to handle theme management tasks. |
| 9 | +SharePoint tenant administrators can use PowerShell cmdlets to create, retrieve, and remove site themes. |
| 10 | + |
| 11 | +Developers can use the SharePoint [REST API](sharepoint-site-theming-rest-api.md) to handle theme management tasks. |
4 | 12 |
|
5 | 13 | For information about how themes are defined and stored, see [JSON schema reference](sharepoint-site-theming-json-schema.md).
|
6 | 14 |
|
7 | 15 | ## Getting started
|
8 | 16 |
|
9 |
| -To run the PowerShell cmdlets for theme management, you'll need to do the following: |
| 17 | +To run the PowerShell cmdlets for theme management, you must do the following: |
10 | 18 |
|
11 | 19 | 1. Download and install the [SharePoint Online Management Shell](https://www.microsoft.com/en-us/download/details.aspx?id=35588). If you already have a previous version of the shell installed, uninstall it first and then install the latest version.
|
| 20 | + |
12 | 21 | 2. Follow the instructions at [Connect to SharePoint Online PowerShell](https://technet.microsoft.com/en-us/library/fp161372.aspx) to connect to your SharePoint tenant.
|
13 | 22 |
|
14 |
| -To verify your setup, try using the **Get-SPOHideDefaultThemes** cmdlet to read the SPOHideDefaultThemes setting. If the cmdlet runs and returns False with no errors, as shown in the following example, you're ready to proceed. |
| 23 | +To verify your setup, try using the [Get-SPOHideDefaultThemes](https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/Get-SPOHideDefaultThemes?view=sharepoint-ps) cmdlet to read the SPOHideDefaultThemes setting. If the cmdlet runs and returns False with no errors, as shown in the following example, you're ready to proceed. |
15 | 24 |
|
16 |
| -```powershell |
17 |
| -c:\> Get-SPOHideDefaultThemes |
18 |
| -False |
19 |
| -``` |
20 | 25 | ## Site theme cmdlets
|
21 | 26 |
|
22 | 27 | The following cmdlets are available for managing site themes from PowerShell:
|
23 | 28 |
|
24 |
| -* **Add-SPOTheme** — Creates a new custom theme, or overwrites an existing theme to modify its settings. |
25 |
| -* **Get-SPOTheme** — Retrieves settings for an existing theme. |
26 |
| -* **Remove-SPOTheme** — Removes a theme from the theme gallery. |
27 |
| -* **Set-SPOHideDefaultThemes** — Specifies whether the default themes should be available. |
28 |
| -* **Get-SPOHideDefaultThemes** — Queries the current SPOHideDefaultThemes setting. |
29 |
| - |
30 |
| -## Add-SPOTheme |
31 |
| - |
32 |
| -The **Add-SPOTheme** cmdlet creates a new theme or updates an existing theme. The color pallette settings can be passed as either a hash table or a dictionary. |
33 |
| - |
34 |
| -In the following example, a new theme named "Custom Cyan" is created, with color pallette settings that are various shades of cyan. Note that the settings are passed as a hash table. |
35 |
| - |
36 |
| -```powershell |
37 |
| -$themepallette = @{ |
38 |
| - "themePrimary" = "#00ffff"; |
39 |
| - "themeLighterAlt" = "#f3fcfc"; |
40 |
| - "themeLighter" = "#daffff"; |
41 |
| - "themeLight" = "#affefe"; |
42 |
| - "themeTertiary" = "#76ffff"; |
43 |
| - "themeSecondary" = "#39ffff"; |
44 |
| - "themeDarkAlt" = "#00c4c4"; |
45 |
| - "themeDark" = "#009090"; |
46 |
| - "themeDarker" = "#005252"; |
47 |
| - "neutralLighterAlt" = "#f8f8f8"; |
48 |
| - "neutralLighter" = "#f4f4f4"; |
49 |
| - "neutralLight" = "#eaeaea"; |
50 |
| - "neutralQuaternaryAlt" = "#dadada"; |
51 |
| - "neutralQuaternary" = "#d0d0d0"; |
52 |
| - "neutralTertiaryAlt" = "#c8c8c8"; |
53 |
| - "neutralTertiary" = "#a6a6a6"; |
54 |
| - "neutralSecondaryAlt" = "#767676"; |
55 |
| - "neutralSecondary" = "#666666"; |
56 |
| - "neutralPrimary" = "#333"; |
57 |
| - "neutralPrimaryAlt" = "#3c3c3c"; |
58 |
| - "neutralDark" = "#212121"; |
59 |
| - "black" = "#000000"; |
60 |
| - "white" = "#fff"; |
61 |
| - "primaryBackground" = "#fff"; |
62 |
| - "primaryText" = "#333" |
63 |
| - } |
64 |
| -
|
65 |
| -Add-SPOTheme -Name "Custom Cyan" -Palette $themepallette -IsInverted $false |
66 |
| -``` |
67 |
| - |
68 |
| -> [!NOTE] |
69 |
| -> Prior to the December 2017 release of SPO Management Shell, the **Add-SPOTheme** |
70 |
| -> cmdlet required that color pallette settings be passed as a dictionary. We recommend |
71 |
| -> that you use the latest version of the SPO Management Shell, however the following |
72 |
| -> ```HashToDictionary``` function can be used to convert a hash table to a |
73 |
| -> dictionary if needed. |
74 |
| -
|
75 |
| -```powershell |
76 |
| -function HashToDictionary { |
77 |
| - Param ([Hashtable]$ht) |
78 |
| - $dictionary = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]" |
79 |
| - foreach ($entry in $ht.GetEnumerator()) { |
80 |
| - $dictionary.Add($entry.Name, $entry.Value) |
81 |
| - } |
82 |
| - return $dictionary |
83 |
| -} |
84 |
| -``` |
85 |
| -If you want to update an existing theme (to modify some of its color settings, for example), use the same syntax as shown previously but add the *-Overwrite* flag to the **Add-SPOTheme** cmdlet. |
86 |
| - |
87 |
| -```powershell |
88 |
| -Add-SPOTheme -Name "Custom Cyan" -Palette $themepallette -IsInverted $false -Overwrite |
89 |
| -``` |
90 |
| -Adding a theme does not apply the theme to any sites. It adds the theme to your tenant store, and then the theme will be available in the list of themes under the **Change the look** option for modern pages. |
91 |
| - |
92 |
| -## Get-SPOTheme |
93 |
| - |
94 |
| -The **Get-SPOTheme** cmdlet returns the settings for a named existing theme, or for all uploaded themes if no name is provided. |
95 |
| - |
96 |
| -Here's how to use the **Get-SPOTheme** cmdlet to return the settings for the "Custom Cyan" theme created in the previous example. |
97 |
| - |
98 |
| -```powershell |
99 |
| -C:\> Get-SPOTheme -Name "Custom Cyan" | ConvertTo-Json |
100 |
| -``` |
101 |
| -```json |
102 |
| -{ |
103 |
| - "Name": "Custom Cyan", |
104 |
| - "Palette": { |
105 |
| - "themeLight": "#affefe", |
106 |
| - "themeTertiary": "#76ffff", |
107 |
| - "black": "#000000", |
108 |
| - "neutralSecondary": "#666666", |
109 |
| - "neutralTertiaryAlt": "#c8c8c8", |
110 |
| - "themeSecondary": "#39ffff", |
111 |
| - "themeDarker": "#005252", |
112 |
| - "primaryBackground": "#fff", |
113 |
| - "neutralQuaternary": "#d0d0d0", |
114 |
| - "neutralPrimaryAlt": "#3c3c3c", |
115 |
| - "neutralPrimary": "#333", |
116 |
| - "themeDark": "#009090", |
117 |
| - "themeLighter": "#daffff", |
118 |
| - "neutralTertiary": "#a6a6a6", |
119 |
| - "neutralQuaternaryAlt": "#dadada", |
120 |
| - "themeLighterAlt": "#f3fcfc", |
121 |
| - "white": "#fff", |
122 |
| - "neutralSecondaryAlt": "#767676", |
123 |
| - "neutralLighter": "#f4f4f4", |
124 |
| - "neutralLight": "#eaeaea", |
125 |
| - "neutralDark": "#212121", |
126 |
| - "themeDarkAlt": "#00c4c4", |
127 |
| - "neutralLighterAlt": "#f8f8f8", |
128 |
| - "primaryText": "#333", |
129 |
| - "themePrimary": "#00ffff" |
130 |
| - }, |
131 |
| - "IsInverted": false |
132 |
| -} |
133 |
| -``` |
134 |
| -Note that this example uses the PowerShell _ConvertTo-Json_ filter to display the theme in JSON format. |
135 |
| - |
136 |
| -To return all uploaded themes, use the **Get-SPOTheme** command with no arguments: |
137 |
| - |
138 |
| -```powershell |
139 |
| -C:\> Get-SPOTheme |
140 |
| -``` |
141 |
| - |
142 |
| -Here's an example of the output from this command: |
143 |
| - |
144 |
| - |
145 |
| - |
146 |
| -## Remove-SPOTheme |
147 |
| - |
148 |
| -The **Remove-SPOTheme** cmdlet removes a theme from your tenant store. For example, this cmdlet removes the "Custom Cyan" theme that was used in the previous examples. |
149 |
| - |
150 |
| -```powershell |
151 |
| -c:\> Remove-SPOTheme -Name "Custom Cyan" |
152 |
| -``` |
153 |
| -## Set-SPOHideDefaultThemes |
154 |
| - |
155 |
| -> [!NOTE] |
156 |
| -> This cmdlet was named ```Set-HideDefaultThemes``` until the December 2017 release of SPO Management Shell. We recommend that you use the latest version of the PowerShell cmdlets. |
157 |
| -
|
158 |
| -The **Set-SPOHideDefaultThemes** cmdlet is used to specify whether the default themes that come with SharePoint should be included in the theme picker list. For example, you might want to create custom themes for your sites and then remove the default themes, to ensure that all pages will use your custom themes. |
159 |
| - |
160 |
| -Specify the setting as either _$true_ to hide the default themes, or _$false_ (the default setting) to allow use of the default themes. For example, this cmdlet hides the default themes. |
161 |
| - |
162 |
| -```powershell |
163 |
| -Set-SPOHideDefaultThemes $true |
164 |
| -``` |
165 |
| -After creating the "Custom Cyan" theme, hiding the default themes will leave only the one custom theme in the themes list under **Change the look**. |
166 |
| - |
167 |
| -To restore the default themes to the theme picker list, use the following cmdlet. |
168 |
| -```powershell |
169 |
| -Set-SPOHideDefaultThemes $false |
170 |
| -``` |
171 |
| - |
172 |
| -## Get-SPOHideDefaultThemes |
173 |
| - |
174 |
| -> [!NOTE] |
175 |
| -> this cmdlet was named ```Get-HideDefaultThemes``` until the December 2017 release of SPO Management Shell. We recommend that you use the latest version of the PowerShell cmdlets. |
176 |
| -
|
177 |
| -The **Get-SPOHideDefaultThemes** cmdlet retrieves the currrent **Set-SPOHideDefaultThemes** setting. You might want to use this cmdlet in a PowerShell script to read the setting and then take different actions based on whether the default themes are hidden. This cmdlet does not have any parameters. |
178 |
| - |
179 |
| -```powershell |
180 |
| -c:\> Get-SPOHideDefaultThemes |
181 |
| -False |
182 |
| -``` |
| 29 | +* [Add-SPOTheme](https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/Add-SPOTheme?view=sharepoint-ps) – Creates a new custom theme, or overwrites an existing theme to modify its settings. |
| 30 | +* [Get-SPOTheme](https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/Get-SPOTheme?view=sharepoint-ps) – Retrieves settings for an existing theme. |
| 31 | +* [Remove-SPOTheme](https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/Remove-SPOTheme?view=sharepoint-ps) – Removes a theme from the theme gallery. |
| 32 | +* [Set-SPOHideDefaultThemes](https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/Set-SPOHideDefaultThemes?view=sharepoint-ps) – Specifies whether the default themes should be available. |
| 33 | +* [Get-SPOHideDefaultThemes](https://docs.microsoft.com/en-us/powershell/module/sharepoint-online/Get-SPOHideDefaultThemes?view=sharepoint-ps) – Queries the current SPOHideDefaultThemes setting. |
| 34 | + |
183 | 35 |
|
184 | 36 | ## See also
|
185 | 37 |
|
186 | 38 | * [SharePoint site theming overview](sharepoint-site-theming-overview.md)
|
187 |
| -* [SharePoint site theming: JSON schema](sharepoint-site-theming-json-schema.md) |
188 | 39 | * [SharePoint site theming: CSOM](sharepoint-site-theming-csom.md)
|
189 |
| -* [SharePoint site theming: REST API](sharepoint-site-theming-rest-api.md) |
190 |
| -* [SharePoint Online Management Shell](https://www.microsoft.com/en-us/download/details.aspx?id=35588) |
191 |
| -* [Connect to SharePoint Online PowerShell](https://technet.microsoft.com/en-us/library/fp161372.aspx) |
| 40 | + |
| 41 | + |
| 42 | + |
0 commit comments