Add-SPOTheme
创建新的自定义主题,或覆盖现有主题以修改其设置。
语法
NewThemeSet
Add-SPOTheme
[-Identity] <SpoThemePipeBind>
-ColorPairs <SpoThemeColorPairPipeBind>
[-Overwrite]
[<CommonParameters>]
LegacyThemeSet
Add-SPOTheme
[-Identity] <SpoThemePipeBind>
-Palette <SpoThemePalettePipeBind>
-IsInverted <Boolean>
[-Overwrite]
[<CommonParameters>]
说明
此 cmdlet 将创建新主题或更新现有主题。 颜色对设置可以作为哈希表传递,而调色板设置可以作为哈希表或字典传递。
添加主题不会自动应用于任何网站。 相反,主题将在新式 SharePoint 页面的 “更改外观 ”选项下的主题列表中可用。
根据使用的是旧主题格式还是新式主题格式,选择适当的参数集。 有关新主题格式的详细信息,请参阅 网站主题。
注意
在多地理位置环境中,管理员在主要地理位置添加的主题会自动传播并在整个组织内可用。 附属地理位置中的管理员不支持此 cmdlet。
示例
示例 1:
$colorPairs = @{
light = @(
@{ "accentColor" = "#03787C"; "backgroundColor" = "#FFFFFF" }
@{ "accentColor" = "#FFFFFF"; "backgroundColor" = "#03787C" }
@{ "accentColor" = "#E3FFFD"; "backgroundColor" = "#03787C" }
@{ "accentColor" = "#03787C"; "backgroundColor" = "#E3FFFD" }
@{ "accentColor" = "#FFF9E3"; "backgroundColor" = "#03787C" }
@{ "accentColor" = "#03787C"; "backgroundColor" = "#FFF9E3" }
@{ "accentColor" = "#03787C"; "backgroundColor" = "#F5F5F5" }
@{ "accentColor" = "#242424"; "backgroundColor" = "#F5F5F5" }
@{ "accentColor" = "#155473"; "backgroundColor" = "#FFFFFF" }
@{ "accentColor" = "#FFFFFF"; "backgroundColor" = "#155473" }
@{ "accentColor" = "#155473"; "backgroundColor" = "#E3FFFD" }
@{ "accentColor" = "#E3FFFD"; "backgroundColor" = "#155473" }
@{ "accentColor" = "#FFF9E3"; "backgroundColor" = "#155473" }
@{ "accentColor" = "#155473"; "backgroundColor" = "#FFF9E3" }
)
}
Add-SPOTheme -Identity "Teal Theme" -ColorPairs $colorPairs
此示例创建一个名为 "Teal Theme" 的主题,该主题具有各种青色色调的颜色对设置。
示例 2:
Add-SPOTheme -Identity "Teal Theme" -ColorPairs $colorPairs -Overwrite
若要以新格式更新现有主题,请使用与创建主题时相同的语法修改颜色设置。 将 -Overwrite 标志添加到 Add-SPOTheme cmdlet。
示例 3:
$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 Cyan" -Palette $themepalette -IsInverted $false
在此示例中,创建了一个名为 "Custom Cyan" 的主题,其调色板设置是各种青色底纹。 请注意,设置作为哈希表传递。
注意
在 2017 年 12 月发布的 SPO 命令行管理程序之前, Add-SPOTheme cmdlet 要求将调色板设置作为字典传递。 建议使用最新版本的 SPO 命令行管理程序,或者根据需要使用 HashToDictionary 函数将哈希表转换为字典。
示例 4:覆盖旧格式主题
Add-SPOTheme -Identity "Custom Cyan" -Palette $themepalette -IsInverted $false -Overwrite
若要更新现有旧格式主题并修改其颜色设置,请使用与创建主题时相同的语法。 将 -Overwrite 标志添加到 Add-SPOTheme cmdlet。
参数
-ColorPairs
适用:SharePoint Online
使用槽值的哈希表指定主题的颜色对。 最多支持 16 个颜色对。
参数属性
| 类型: | Microsoft.Online.SharePoint.PowerShell.SpoThemeColorPairPipeBind |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
NewThemeSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Identity
适用:SharePoint Online
指定主题的名称。 这必须唯一标识主题。
参数属性
| 类型: | Microsoft.Online.SharePoint.PowerShell.SpoThemePipeBind |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | 名称 |
参数集
(All)
| Position: | 0 |
| 必需: | True |
| 来自管道的值: | True |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-IsInverted
适用:SharePoint Online
指定主题是否反转,背景为深色和浅色前景。
参数属性
| 类型: | System.Boolean |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | None |
参数集
LegacyThemeSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Overwrite
适用:SharePoint Online
覆盖同名主题(如果存在)。
参数属性
| 类型: | System.Management.Automation.SwitchParameter |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
| 别名: | None |
参数集
(All)
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
-Palette
适用:SharePoint Online
指定主题中的调色板,作为主题槽值的字典或哈希表。
参数属性
| 类型: | Microsoft.Online.SharePoint.PowerShell.SpoThemePalettePipeBind |
| 默认值: | None |
| 支持通配符: | False |
| 不显示: | False |
参数集
LegacyThemeSet
| Position: | Named |
| 必需: | False |
| 来自管道的值: | False |
| 来自管道的值(按属性名称): | False |
| 来自剩余参数的值: | False |
CommonParameters
此 cmdlet 支持通用参数:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 有关详细信息,请参阅 about_CommonParameters。