So I have a working script that will deploy a basic planner from a CSV with categories Bucket, Tasks, Description, Start Date, Due Date, etc. But the requester is now wanting some of the tasks to have checklists in addition to the description and per MS that info must be in a hashtable, which I have never worked with.
Here is a sample of my CSV. Do I just add another column for checklist items? Does each item need its own row?
enter image description here
And here is a sample of the relevant code:
# Add Tasks to Buckets
write-host "Adding Tasks to Buckets..." -ForegroundColor Yellow
foreach ($Task in $PlanTemplate) {
if ($PlanTemplate.Details -ne "") {
$CurrentBucket = $BucketList | Where-Object { $_.name -eq $Task.Bucket }
try {
$params = @{
planId = "$($newPlan.id)"
bucketId = "$($CurrentBucket.id)"
title = "$($Task.task)"
startdatetime = "$($Task.startdate)"
duedatetime = "$($Task.duedate)"
}
$CreatedTask = New-MgPlannerTask -BodyParameter $params
}
catch {
write-error "Could not create task: $($task.task), Error:`n $_"
exit
}
$params = @{
description = "$($Task.details)"
previewType = "$($Task.previewtype)"
}
# Add Details to Tasks
try {
Update-MgPlannerTaskDetail -PlannerTaskId $CreatedTask.Id -BodyParameter $params -IfMatch (Get-MgPlannerTaskDetail -PlannerTaskId $CreatedTask.id).AdditionalProperties["@odata.etag"]
}
catch {
write-error "Could not update task details: $($task.task), Error:`n $_"
exit
}
Not really sure what to try
Justin is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.