使用 PowerShell 在 SharePoint 中创建任务列表
要求: 在 SharePoint 中,使用 PowerShell 创建任务列表!
PowerShell 在 SharePoint 中创建任务列表:
让我向您展示如何使用 PowerShell 在 SharePoint 中创建任务列表:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Variables
$WebURL="https://intranet.crescent.com"
$ListName="Project Tasks"
$ListDescription ="Task list to manage project tasks"
#Task list template
$ListTemplate = [Microsoft.SharePoint.SPListTemplateType]::Tasks
#Get the Web
$Web = Get-SPWeb $WebURL
#Check if the task list exists already
$TaskList = $Web.Lists.TryGetList($ListName)
if($TaskList -ne $null)
{
Write-host "Task list '$($ListName)' exists already!" -ForegroundColor Red
}
else
{
#Create the task list
$Web.Lists.Add($ListName,$ListDescription,$ListTemplate) | Out-Null
#Set "Show in Quick Launch" property for the list
$TaskList = $Web.Lists[$ListName]
$TaskList.OnQuickLaunch = $True
$TaskList.Update()
Write-host "Task list '$($ListName)' Created successfuly!" -ForegroundColor Green
}
此 PowerShell 脚本创建一个 SharePoint 任务列表。
要使用 PowerShell 在任务列表中添加任务,请使用:使用 PowerShell 在 SharePoint 任务列表中创建任务
