Creating a Planner Weekly Notification Email for Incomplete Tasks

Incomplete Task Analysis Report is Good, but an Email Detailing Incomplete Tasks Might Be Better

A reader noted the script I wrote in 2023 to analyze incomplete tasks in Planner plans and asked had I a version that emailed incomplete task lists to individual team members. My response was that I hadn’t, but it would be easy to amend the code to split up the results for individual users and email a listing of incomplete tasks to each user. After all, it’s just PowerShell.

Roll forward a couple of weeks and my correspondent had made no progress. Looking at the script, I could see why the code is a little off-putting to someone who isn’t used to working with Graph APIs through PowerShell (the Automating Microsoft 365 with PowerShell eBook helps here). Handling topics like pagination and retrieving access tokens (not to mention token renewal) is enough to furrow anyone’s brow.

Creating a Planner Notification Email

As it happens, I sort of needed the same thing myself. The Office 365 for IT Pros author team uses message center notifications to keep to date with changes in workloads. It’s not the only source of information that we use, but it’s convenient because the Microsoft 365 admin center offers the option to synchronize the notifications with a Planner plan (something that can also be done with PowerShell).

Although our authors are all very knowledgeable people, they’re not very disciplined at closing off tasks after reviewing new notifications to decide if the change affects the content of their chapters. My idea was therefore to write a script that:

  • A security group holds members who will be checked for incomplete tasks. I call the group “Weekly Task Updates.” Any other valid group could be used.
  • For each member, find the Microsoft 365 groups that they belong to.
  • Check the Microsoft 365 groups for plans and find any incomplete tasks assigned and note their details.
  • Send email as a reminder about the incomplete tasks to ask the recipient to close any tasks out that are no longer valid. The email contains details of the incomplete tasks, including a hyperlink to each task so that the user can quickly check out the task in the Planner browser app.
  • Schedule the script as an Azure Automation runbook to run at 7AM every Saturday (to prompt authors to do some work over the weekend…). Figure 1 is an example of the email.
Incomplete tasks email for Planner user.
Figure 1: An incomplete task report emailed to a user

Planner and the Microsoft Graph PowerShell SDK

To make the code easier to understand, the script uses cmdlets from the Planner module in the Microsoft Graph PowerShell SDK. The script therefore features cmdlets like:

  • Get-MgGroupPlannerPlan: Fetch the plans for the Microsoft 365 group.
  • Get-MgPlannerPlanTask: Fetch the tasks for a plan.
  • Get-MgPlannerPlanBucket: Fetch the buckets for a plan.

Graph Woes for Planner

The Graph implementation for Planner is basic and affects both Graph requests and SDK cmdlets. For example, filtering is unsupported on the percentComplete or completedDateTime properties, so a client-side filter is required to find open tasks after fetching all the tasks in the plan. There’s no support for search or sorting either. The plan that logs message center notifications currently spans 8120 tasks, so the lack of support for optimized queries is a pain when trying to extract incomplete tasks. Here’s how the script finds incomplete tasks:

[array]$Tasks = Get-MgPlannerPlanTask -PlannerPlanId $Plan.Id -All -PageSize 500 -Property Id, Title, CompletedDateTime, StartDateTime, DueDateTime, BucketId, Assignments -ErrorAction Stop
$IncompleteTasks = $Tasks | Where-Object { $null -eq $_.CompletedDateTime }

There’s also no Graph API to find the set of plans in which a user has assigned tasks. Everything flows through Microsoft 365 groups. I didn’t just want to report the open tasks found in the plan synchronized with the Microsoft 365 admin center because it seemed more useful to report open tasks found in any plan. Certainly, this is better for me because I think it’s useful to send people a single message containing a consolidated list of all their incomplete tasks instead of a separate message per plan.

Azure Automation Setup

After testing to make sure that the code ran interactively, I moved it over to Azure Automation to create a runbook. As described in this article, two issues need to be dealt with for scripts that use the Microsoft Graph PowerShell SDK: Graph permissions assigned to the automation account and SDK sub-modules loaded into the runtime environment. Details of the requirements are in the script.

Hopefully, the script is useful. If not, feel free to suggest amendments through the Office 365 for IT Pros GitHub repository.


Support the work of the Office 365 for IT Pros team by subscribing to the Office 365 for IT Pros eBook. Your support pays for the time we need to track, analyze, and document the changing world of Microsoft 365 and Office 365. Only humans contribute to our work!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.