I want to get the start date and the Due date for a task which will be repeated Annually using Powershell Please.
1 Answer
The solution is :
$today= Get-Date
$dueDate = (get-date).AddYears(1)
if ($today.DayOfWeek -eq "Monday" -and $today.Day -le "7" -and $today.Month -eq "1")
{
foreach($item1 in $listSource1.Items | Where {$_["Frequency"] -eq "Annually"})
{
$newItem = $listTarget.Items.Add();
$newItem["StartDate"] = $today.ToShortDateString()
$newItem["DueDate"] = $dueDate.ToShortDateString()
newItem.Update()
}
}