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

[玩转系统] 使用 PowerShell 创建 SharePoint 链接列表

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

使用 PowerShell 创建 SharePoint 链接列表


要求:使用 PowerShell 在 SharePoint 中创建链接列表

以下是在 SharePoint 中创建链接列表的 PowerShell 脚本:


Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

Function Create-LinkList($WebURL, $ListName, $ListDescription)
{
    try
    {
        $ErrorActionPreference ="Stop" 

        #Get the Web
        $Web = Get-SPWeb $WebURL

        #Get link list template
        $LinkListTemplate = [Microsoft.SharePoint.SPListTemplateType]::Links
        
        #Create link list
        $web.Lists.Add($ListName,$ListDescription,$LinkListTemplate)

        write-host "New List has been created!" -foregroundcolor Green
    }
    catch [System.SystemException]
    {
        write-host "List Creation failed due to:" $_.Exception.Message -foregroundcolor Red
    }
    finally
    {
        #Dispose web object
        $web.Dispose()
        $ErrorActionPreference ="Continue" 
    }
}

#Call the function to create a Link list
Create-LinkList "https://sharepoint.creswcent.com/" "Quick Links" "List of frequently accessed sites"

有关所有列表模板类型,请参阅 Microsoft 文档:https://docs.microsoft.com/en-us/dotnet/api/microsoft.sharepoint.splisttemplatetype?view=sharepoint-server

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

取消回复欢迎 发表评论:

关灯