The New-MgUserTodoListTask cmdlet in Microsoft Graph PowerShell is a powerful tool for creating tasks in a specific To-Do list for users in your organization. This cmdlet enables IT administrators to streamline task management operations by automating the creation of tasks for individuals or in bulk. Whether you’re assigning individual tasks, multiple tasks, or creating tasks from a CSV file, this guide covers it all.
New-MgUserTodoListTask -UserId <String> -TodoTaskListId <String> -BodyParameter <PSObject>
Required Parameters:
Create a task with specific details such as a title, due date, and priority.
$TaskDetails = @{
title = "Prepare Quarterly Report"
dueDateTime = @{ dateTime = "2024-11-15T17:00:00"; timeZone = "UTC" }
importance = "high"
}
New-MgUserTodoListTask -UserId "john.doe@contoso.com" -TodoTaskListId "A1B2C3D4" -BodyParameter $TaskDetails
Create multiple tasks for a user by iterating through a list of task details.
$Tasks = @(
@{ title = "Complete Budget Analysis"; dueDateTime = @{ dateTime = "2024-11-18T17:00:00"; timeZone = "UTC" }; importance = "normal" },
@{ title = "Team Meeting Preparation"; dueDateTime = @{ dateTime = "2024-11-20T10:00:00"; timeZone = "UTC" }; importance = "low" }
)
foreach ($Task in $Tasks) {
New-MgUserTodoListTask -UserId "john.doe@contoso.com" -TodoTaskListId "A1B2C3D4" -BodyParameter $Task
}
Use a CSV file to create tasks for multiple users. The CSV should contain columns for UserId, TodoTaskListId, Title, DueDateTime, and Importance.
$Tasks = Import-Csv "Tasks.csv"
foreach ($Task in $Tasks) {
$TaskDetails = @{
title = $Task.Title
dueDateTime = @{ dateTime = $Task.DueDateTime; timeZone = "UTC" }
importance = $Task.Importance
}
New-MgUserTodoListTask -UserId $Task.UserId -TodoTaskListId $Task.TodoTaskListId -BodyParameter $TaskDetails
}
Error | Cause | Solution |
InvalidAuthenticationToken | The user account lacks proper permissions to execute the cmdlet. | Ensure the account has the Tasks.ReadWrite permission in Microsoft Graph. |
ResourceNotFound | The TodoTaskListId provided does not exist or is incorrect. | Use Get-MgUserTodoList to retrieve the correct list ID. |
BadRequest | Incorrect or missing properties in the -BodyParameter. | Ensure required properties such as title and dueDateTime are included. |
The New-MgUserTodoListTask cmdlet is an invaluable tool for task automation in Microsoft 365 environments. By leveraging its capabilities, administrators can efficiently manage user workloads, ensure deadlines are met, and improve task assignment workflows. Whether you're creating a single task or handling bulk assignments via CSV, this cmdlet simplifies the process with precision and flexibility.
© M365Corner. All Rights Reserved. Design by HTML Codex.