kwizcom banner advertisement

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
$WebURL="http://intranet.crescent.com"
$TaskListName="Tasks"

#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["AssignedTo"]=$web.EnsureUser("Crescent\Salaudeen")
$NewTaskItem["StartDate"]= (Get-Date).ToShortDateString()
$NewTaskItem["DueDate"] =(Get-Date).AddDays(7)
$NewTaskItem["Status"]="Not Started"
$NewTaskItem["Priority"]= "(1) High"
$NewTaskItem["PercentComplete"]="0"

$NewTaskItem.Update()

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
Create a Task in SharePoint Task List using Powershell Create a Task in SharePoint Task List using Powershell Reviewed by Salaudeen Rajack on 7:00 PM Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.