使用 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