Skip to content

Commit 4fcb68b

Browse files
author
Doug Mahugh
authored
Merge pull request SharePoint#1173 from dmahugh/dmahugh-dec2017-7206
update documentation to reflect resolution of bugs 422068 and 453386
2 parents f1de5b5 + f04fba4 commit 4fcb68b

File tree

2 files changed

+36
-17
lines changed

2 files changed

+36
-17
lines changed

docs/declarative-customization/site-theming/sharepoint-site-theming-powershell.md

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,12 @@ The following cmdlets are available for managing site themes from PowerShell:
2929

3030
## Add-SPOTheme
3131

32-
The **Add-SPOTheme** cmdlet creates a new theme or updates an existing theme. The color pallette settings are passed as a dictionary.
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.
3333

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 this example uses a ```HashToDictionary``` function to convert a hash table created with the ```@{}``` notation into a dictionary, as required by **Add-SPOTheme**.
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.
3535

3636
```powershell
37-
function HashToDictionary {
38-
Param ([Hashtable]$ht)
39-
$dictionary = New-Object "System.Collections.Generic.Dictionary``2[System.String,System.String]"
40-
foreach ($entry in $ht.GetEnumerator()) {
41-
$dictionary.Add($entry.Name, $entry.Value)
42-
}
43-
return $dictionary
44-
}
45-
46-
$themepallette = HashToDictionary(
47-
@{
37+
$themepallette = @{
4838
"themePrimary" = "#00ffff";
4939
"themeLighterAlt" = "#f3fcfc";
5040
"themeLighter" = "#daffff";
@@ -71,10 +61,27 @@ $themepallette = HashToDictionary(
7161
"primaryBackground" = "#fff";
7262
"primaryText" = "#333"
7363
}
74-
)
7564
7665
Add-SPOTheme -Name "Custom Cyan" -Palette $themepallette -IsInverted $false
7766
```
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+
```
7885
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.
7986

8087
```powershell
@@ -84,7 +91,9 @@ Adding a theme does not apply the theme to any sites. It adds the theme to your
8491

8592
## Get-SPOTheme
8693

87-
The **Get-SPOTheme** cmdlet returns the settings for an existing theme. For example, here's how to use the **Get-SPOTheme** cmdlet to return the settings for the "Custom Cyan" theme created in the previous example.
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.
8897

8998
```powershell
9099
C:\> Get-SPOTheme -Name "Custom Cyan" | ConvertTo-Json
@@ -124,6 +133,16 @@ C:\> Get-SPOTheme -Name "Custom Cyan" | ConvertTo-Json
124133
```
125134
Note that this example uses the PowerShell _ConvertTo-Json_ filter to display the theme in JSON format.
126135

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+
![Get-SPOTheme example](../../images/Get-SPOTheme-example.png)
145+
127146
## Remove-SPOTheme
128147

129148
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.
@@ -134,7 +153,7 @@ c:\> Remove-SPOTheme -Name "Custom Cyan"
134153
## Set-SPOHideDefaultThemes
135154

136155
> [!NOTE]
137-
> this cmdlet was named as ```Set-HideDefaultThemes``` until December 2017 release of SPO Management Shell. We recommend that you'd use the latest version of the PowerShell cmdlets.
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.
138157
139158
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.
140159

@@ -153,7 +172,7 @@ Set-SPOHideDefaultThemes $false
153172
## Get-SPOHideDefaultThemes
154173

155174
> [!NOTE]
156-
> this cmdlet was named as ```Get-HideDefaultThemes``` until December 2017 release of SPO Management Shell. We recommend that you'd use the latest version of the PowerShell cmdlets.
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.
157176
158177
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.
159178

docs/images/Get-SPOTheme-example.png

17.8 KB
Loading

0 commit comments

Comments
 (0)