Create a Task in SharePoint Task List using Powershell

PowerShell Script to Create a New Task in SharePoint Task List:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Configuration Parameters

#Get web and List objects
$Web = Get-SPWeb $WebURL
$TaskList = $Web.Lists[$TaskListName]

$NewTaskItem = $TaskList.AddItem()

#Set value for Task list columns
$NewTaskItem["Title"] = "New Task"
$NewTaskItem["StartDate"]= (Get-Date).ToShortDateString()
$NewTaskItem["DueDate"] =(Get-Date).AddDays(7)
$NewTaskItem["Status"]="Not Started"
$NewTaskItem["Priority"]= "(1) High"


Write-host "New Task Item Created Successfully!"
and here is the new task created in SharePoint 2016 task list:
create new task item in Task list of SharePoint using PowerShell

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.