当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] SharePoint Online:使用 PowerShell 删除自定义主题

作者:精品下载站 日期:2024-12-14 15:32:41 浏览:17 分类:玩电脑

SharePoint Online:使用 PowerShell 删除自定义主题


要求:删除 SharePoint Online 中的自定义主题。

如果您曾经通过添加自定义主题来自定义 SharePoint Online 网站,那么您稍后可能会发现您不喜欢该主题的外观和风格。或者,您组织中的其他人可能创建了您希望避免使用的自定义主题。当您在 SharePoint Online 中创建自定义主题时,可以轻松添加到您的网站。但如果您想删除它怎么办?通过使用 PowerShell,可以轻松删除自定义主题并清理租户。本指南将向您展示如何从 SharePoint Online 租户中删除自定义主题。让我们开始吧!

单击屏幕右上角的齿轮图标并选择“站点设置”,打开“站点设置”页面:然后在“外观和感觉”下,单击“主题”。您将看到站点上当前安装的自定义主题的列表。

[玩转系统] SharePoint Online:使用 PowerShell 删除自定义主题

使用 PowerShell 删除 SharePoint Online 中的主题:

我们可以使用Remove-SPOTheme cmdlet 从SharePoint Online 租户中删除自定义主题。请记住,一旦删除自定义主题,它就无法恢复,因此在继续之前请确保这是您想要执行的操作。


Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking

$TenantAdminURL = "https://crescent-admin.sharepoint.com"
$ThemeName = "Corporate Theme"

#Connect-SPOService -Url $TenantAdminURL -Credential (Get-Credential)

#Get the custom theme to delete
$CustomTheme = Get-SPOTheme | Where {$_.Name -eq $ThemeName }
If($CustomTheme -ne $null)
{
    #Delete theme
    Remove-SPOTheme -Identity $ThemeName 
    Write-Host "Theme '$ThemeName' Removed Successfully!" -f Green
}
Else
{
    Write-Host "Theme '$ThemeName' doesn't exist!" -f Yellow
}

SharePoint Online:用于删除主题的 PowerShell

我们还可以使用 PnP PowerShell 删除 SharePoint Online 中的主题:


#Config Variables
$AdminSiteURL = "https://crescent-Admin.sharepoint.com"
$ThemeName = "Corporate Theme"

#Connect to PnP Online
Connect-PnPOnline -Url $AdminSiteURL -Interactive

#Get the Custom Theme
$Theme = Get-PnPTenantTheme | Where {$_.Name -eq $ThemeName}

If ($Theme.Count -eq 0) 
{ 
    Write-host "The specified Theme '$themeName' doesn't exist!" -ForegroundColor Yellow
    Break; 
}

#Remove the Theme
Remove-PnPTenantTheme -name $Theme.Name
Write-host "Custom Theme '$ThemeName' Removed Successfully!" -ForegroundColor Green

如果删除自定义主题,任何使用该特定主题的网站都不会产生任何效果!它们将继续使用已删除主题的颜色,直到您将其更改为新主题。

结论

总之,使用 PowerShell 在 SharePoint Online 中删除自定义主题是一个相对简单的过程,需要一些基本命令。它允许清理您的 SharePoint 环境并从主题列表中删除不必要的主题。要删除自定义主题,您需要使用 PowerShell 连接到 SharePoint Online 租户,然后需要使用 Remove-SPOTheme 或 Remove-PnPTheme cmdlet 来删除主题。通过执行这些步骤,您应该能够使用 PowerShell 成功删除自定义主题。请务必注意,在删除任何主题之前,请确保您已确认任何网站不再需要或使用该主题。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯