2

I want to get the start date and the Due date for a task which will be repeated Annually using Powershell Please.

3

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()
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.