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

[玩转系统] SharePoint Online:如何使用 PowerShell 更改网站标题(名称)?

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

SharePoint Online:如何使用 PowerShell 更改网站标题(名称)?


要求:更改 SharePoint Online 中的网站标题。

SharePoint Online:如何更改网站名称?

您可能出于多种原因(例如品牌)想要更改 SharePoint 网站的名称。这篇博文将引导您了解如何快速轻松地在 Office 365 中更改 SharePoint 网站的名称!

如何更改 SharePoint Online 网站的名称?那么,要更改 SharePoint Online 中的网站集标题,请按照下列步骤操作:

  1. 转到站点设置页面 >> 单击“外观和感觉”下的“标题、描述和徽标”链接。
  2. 输入网站或网站集的新标题。

    [玩转系统] SharePoint Online:如何使用 PowerShell 更改网站标题(名称)?

  3. 单击“确定”保存更改。就是这样!这会更改站点名称。您的新站点名称将显示在主页和浏览器选项卡中。现在,让我们使用 PowerShell 更改 SharePoint Online 中的网站名称。

如何更改现代 SharePoint Online 网站中的网站名称?

网站名称是在创建网站集或子网站时指定的。但是,如果您想更改站点名称,请按照以下步骤操作:

  1. 登录到您要更改名称的网站。单击“设置”齿轮 >> 单击“站点信息”链接。
  2. 输入“站点名称”值并单击“保存”以将名称更改为您的 SharePoint 站点。

    [玩转系统] SharePoint Online:如何使用 PowerShell 更改网站标题(名称)?

在“站点信息”面板中,您还可以更新站点描述,然后单击“保存”按钮。

PowerShell 在 SharePoint Online 中更改网站标题:

让我们看看用于更改 SharePoint Online 网站名称的 PowerShell 脚本。以下是用于更改 SharePoint Online 中的网站或网站集标题的 PowerShell。


#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

#Variables
$SiteURL="https://Crescent.sharepoint.com/us"
$NewSiteTitle="United States"
$NewSiteDescription = "US Team Site"

Try {
    $Cred= Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
 
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Credentials

    #Get the Site from URL
    $Web = $Ctx.web
    $Ctx.Load($web)
    $Ctx.ExecuteQuery()
 
    #Get the current site title
    Write-host "Site Title:"$web.title

    #sharepoint online powershell change site title
    $web.title = $NewSiteTitle

    #change sharepoint online site description
    $web.description = $NewSiteDescription

    $Web.Update()
    $Ctx.ExecuteQuery()
     
    Write-host "Site Title and Description has been updated!" -ForegroundColor Green  
}
Catch {
    write-host -f Red "Error Updating Site Title!" $_.Exception.Message
}

此 PowerShell 将网站集名称和描述更改为新名称。

SharePoint Online:使用 PnP PowerShell 更改站点名称

使用 PnP PowerShell 的 Set-PnPWeb cmdlet 更改 SharePoint Online 中的网站名称:


#Config Variables
$SiteURL = "https://Crescent.sharepoint.com/Sales"
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#sharepoint online powershell change site name
Set-PnPWeb -Title "Sales Portal" 

使用 PowerShell 更改 SharePoint Online 网站描述
同样,您可以使用“-Description”参数更新网站的描述。


Set-PnPWeb -Description "Marketing Portal"

若要更改 SharePoint Online 中的网站 URL,请使用如何更改 SharePoint Online 中的网站 URL?

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

取消回复欢迎 发表评论:

关灯