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

[玩转系统] SharePoint Online:使用 PowerShell 更新列表标题、描述、快速启动导航属性

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

SharePoint Online:使用 PowerShell 更新列表标题、描述、快速启动导航属性


要求:在 SharePoint Online 列表中设置标题、说明和快速启动导航设置。

如何更新列表标题、描述和快速启动导航设置?

您可能需要更新列表标题、描述或快速启动导航设置以反映用户不断变化的需求。在这篇博文中,我们将向您展示如何更改 SharePoint Online 中的列表设置。我们将介绍如何修改列表属性,例如重命名列表、设置列表描述以及选择列表是否应显示在快速启动导航中。

若要在 SharePoint Online 中设置列表标题、描述和快速启动导航选项,请执行以下步骤:

  1. 导航到您的目标列表或库。单击“设置”图标,然后单击“库设置”(在经典 SharePoint 中,在“列表”选项卡下,单击功能区中的“列表设置”按钮)

    [玩转系统] SharePoint Online:使用 PowerShell 更新列表标题、描述、快速启动导航属性

  2. 在列表或库设置页面中,单击常规设置下的“列表名称、描述和导航”链接。

    [玩转系统] SharePoint Online:使用 PowerShell 更新列表标题、描述、快速启动导航属性

  3. 常规设置页面,您可以更新列表的标题、列表的说明以及在快速启动导航中显示或隐藏列表的选项。单击“保存”以提交您的更改。

    [玩转系统] SharePoint Online:使用 PowerShell 更新列表标题、描述、快速启动导航属性

PowerShell 设置列表标题、描述和快速启动导航设置

以下是用于更新列表设置的 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"
   
#Config Parameters
$SiteURL= "https://crescent.sharepoint.com/"
$ListName="Project Docs"
 
#Setup Credentials to connect
$Cred = Get-Credential
$Cred = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
 
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = $Cred
   
    #Get the web and List
    $Web=$Ctx.Web
    $List=$web.Lists.GetByTitle($ListName)
  
    #Set List Title, Description and Quick launch Navigation properties
    $List.Title="Project Documentation"
    $List.Description="Document Repository to Store Upcoming Project Artifacts"
    $List.OnQuickLaunch=$True
    $List.Update()
    
    $Ctx.ExecuteQuery()

    Write-host -f Green "List Properties Updated!"
}
Catch {
    write-host -f Red "Error Setting List Properties!" $_.Exception.Message
}

PnP PowerShell 设置列表标题、说明和快速启动属性:

您是否希望使用 PowerShell 更改 SharePoint Online 列表设置?干得好:


#Config Variables
$SiteURL = "https://Crescent.sharepoint.com/sales"
$ListName = "Project Metrics"
#List Properties to update
$ListTitle = "Project Metrics V2"
$ListDescription ="List to capture Project Metrics Version 2"
$OnQuickLaunch = $True

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get the context
$Context = Get-PnPContext

#Get the List
$List = Get-PnPList -Identity $ListName

#Set List Title, Description and On Quick Launch Properties
$List.Title =$ListTitle
$List.Description = $ListDescription
$List.OnQuickLaunch = $OnQuickLaunch
$List.Update() 
$Context.ExecuteQuery()

您还可以使用 Set-PnPList cmdlet 来设置这些属性。例如。,


Set-PnPList -Identity "Documents" -Title "Team Docs" -Description "Team Documents"

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

取消回复欢迎 发表评论:

关灯