- July
Posted By : Zeng Yinghua (Sandy)
PowerShell Module for Microsoft Planner

Recently I fall in love with Microsoft Graph. 🙂 I was honored invited to MMSMOA talk about Intune Graph with David Falkus and Timmy Andersson. We talked about what is Microsoft Graph, how to start use it and how to use Intune Graph PowerShell SDK. Last week,  Tom Degreef asked if there is PowerShell Module for Microsoft Planner. So I did some research, and got an idea that how about make my own PowerShell module for Microsoft Planner using Microsoft Graph. I have never upload anything to PowerShell Gallery, this will full fill my bucket list as well. 🙂

You can find the module directly from PowerShell Gallery and my Github

Let’s break down some details of this module.


The module is using Native Application that hosted in my own tenant by default, it uses permission Group.Read.All, Group.ReadWrite.All, User.Read and User.ReadBasic.All, these are the minimum permission requirement to create Planner plans, buckets and tasks. But, I would really hope you use own application for this module, because it will give you more control of those permissions, or if you wants to add more actions in your scripts. Here are the steps how to create this native app.

  1. Go to your Azure Portal, Click on Azure Active Directory, click on App registrations, then New registration

  2. Input a name example Planner PowerShell. Supported account types choose organizational directory only. You can also use any organizational directory,  if you manage multiple tenants and wants use this app to all your tenants.
    Redirect URI, choose Public client (mobile & desktop), and value as urn:ietf:wg:oauth:2.0:oob

  3. After registered this app, go to Authentication, change Default client type from to Yes, so that this will be  a public native client

  4. Click on API permissions, choose Microsoft Graph, then add Delegated permissions: Group.Read.All, Group.ReadWrite.All, User.Read and User.ReadBasic.All

  5. (Optional) Grant admin consent. This is very much depend on your own environment and usage. Without admin consent, normal users aren’t able to run this application. If you are the only admin who use this app, then you don’t need grant consent to others. But if you want another non-admin person use this module, you should grant admin consent. Because this is using delegated permission, the required permissions will be a combination of 1) what the user has permissions to do and 2) what the application has permissions to do. (Read the details from this blog https://developer.microsoft.com/en-us/graph/blogs/30daysmsgraph-day-11-azure-ad-application-permissions/ )


Update Planner Module environment

After register your own app, copy it’s application client ID to your note.

Then install the PlannerModule, and update the module to use your own application instead of the default one.


How to use this module

At first, this module is not 100% ready, there is no delete function yet, it can create plans, buckets, tasks, assign tasks to users, add checklist, add labels, assign labels, add descriptions, create Office 365 groups, add user to Office 365 groups.  It doesn’t handle “for each” objects, only the Invoke-AssignPlannerTask can add multiple array.

Here are some examples. Note: I will update those example in my Github.

# PlannerModule
PowerShell module for Microsoft Planner


#Check Planner PowerShell module

$PlannerModule = Get-Module -Name "PlannerModule" -ListAvailable

if ($PlannerModule -eq $null)
  Write-host "Planner PowerShell module not found, Start install the module"
  Install-Module "PlannerModule" -AllowClobber -Force

#Connect to Microsoft Planner
Connect-Planner -ForceNonInteractive True

#Definde variables
$GroupName = "A NewPlan 01"
$PlanName = "PowerShell Test Plan 03"
$BucketName = "PowerShell bucket"
$TaskName = "Test Task"

#Create new plan with Private O365 Group (this will also create new O365 Group), can also create public group
#$result01 = New-PlannerPlan -PlanName $PlanName -visibility Private
#$PlannerPlanID = $result01.id

#Create New Office 365 Group
$responde = New-AADUnifiedGroup -GroupName $GroupName -visibility Private
$GroupID = $($responde.id)

#sometimes there is delay creating the group.
Start-Sleep 10

#create new plan using exsiting O365 Group
$responde1 = New-PlannerPlanToGroup -PlanName $PlanName -GroupID $GroupID
$PlannerPlanID = $($responde1.id)

#Create new Bucket
$responde2 = New-PlannerBucket -PlanID $PlannerPlanID -BucketName $BucketName
$PlannerPlanBucketID = $responde2.id

#Create task
$responde3 = New-PlannerTask -PlanID $PlannerPlanID -TaskName $TaskName -BucketID $PlannerPlanBucketID -startDate "2019.6.3" -dueDate "2019.6.30"
$PlannerPlanTaskID = $responde3.id

#Assign task to users
Invoke-AssignPlannerTask -TaskID $PlannerPlanTaskID -UserPrincipalNames "user01@yourdomain.com", "user02@yourdomain.com"

#Add task check list
Add-PlannerTaskChecklist -TaskID $PlannerPlanTaskID -Title "Check1" -IsChecked $false
Add-PlannerTaskChecklist -TaskID $PlannerPlanTaskID -Title "Check2" -IsChecked $true
Add-PlannerTaskChecklist -TaskID $PlannerPlanTaskID -Title "Check3" -IsChecked $false

#add task description
Add-PlannerTaskDescription -TaskID $PlannerPlanTaskID -Description "This is test task created by powershell planner module"

#Add or update labels
Update-PlannerPlanCategories -PlanID $PlannerPlanID -category1 "Kieken" -category2 "smart" -category3 "very smart" -category4 "wise" -category5 "something"

#Assign Planner Task lables
Invoke-AssignPlannerTaskCategories -TaskID $PlannerPlanTaskID -category1 $false -category2 $true -category3 $true -category4 $false -category5 $false -category6 $false


Hope you like this module. 🙂





  • Hi Sandy,
    I’ve been needing to import existing data into planner – so thank you very much for this. I have been filling out the module slightly – to make a few calls more consistent and idempotent.

    I noticed a typo in a cmdlet name: Update-PlannerModuleEnvironment – not: Update-PlannerModuelEnvironment
    I also noticed you are using Invoke in some places where Get might be more appropriate?

    currently – I am trying to get the comments/attachments going – to complete the import functionality.

    ———————————— please see below for code ———————————

    $BaseURI = “https://graph.microsoft.com/beta”

    function Invoke-PlannerRestMethod {
    Param (
    [String] $uri,
    [ValidateSet(“GET”, “POST”)][String] $Method=”GET”,
    [String] $Body=””

    try {
    if (!($uri.StartsWith(“https://”))) {
    $uri = $BaseURI + $uri
    if ($Body) {
    Invoke-RestMethod -Uri $uri -Headers $authToken -Method $Method -Body $Body
    else {
    Invoke-RestMethod -Uri $uri -Headers $authToken -Method $Method

    Catch {
    $ex = $_.Exception
    if ($($ex.Response.StatusDescription) -match ‘Unauthorized’)
    Write-Error “Unauthorized, Please check your permissions and use the ‘Connect-Planner’ command to authenticate”
    Write-Error “Request to $Uri failed with HTTP Status $($ex.Response.StatusCode) $($ex.Response.StatusDescription)”

    function Get-PlannerPlanList {
    param ([String] $GroupId)
    return (Invoke-PlannerRestMethod -uri “/Groups/$GroupID/planner/plans”).value
    function Get-PlannerPlanDetails {
    param ([String] $PlanId)
    return (Invoke-PlannerRestMethod -uri “/planner/plans/$planid/details”)
    function Get-PlannerBucketList {
    param ([String] $PlanId)
    return (Invoke-PlannerRestMethod -uri “/planner/plans/$PlanId/buckets”).value
    function Get-PlannerBucketDetails {
    param ([String] $BucketId)
    return (Invoke-PlannerRestMethod -uri “/planner/buckets/$BucketId”)
    function Get-PlannerTaskList {
    param ([String] $BucketId)
    return (Invoke-PlannerRestMethod -uri “/planner/buckets/$BucketId/tasks”).value
    function Set-BucketTask {
    param (
    [String] $PlanId, # Need to supply either planId or BucketId
    [String] $BucketId,
    [String] $TaskName,
    [String] $TaskDescription,
    [Array] $UserPrincipalNames,
    [DateTime] $StartDate = (Get-Date),
    [DateTime] $dueDate
    if ($BucketId) {
    $PlanId = (Get-PlannerBucketDetails -BucketId $BucketId).PlanID
    else {
    $BucketId = (Get-PlannerBucketList -PlanId $PlanId)[0].BucketId # Get the default bucket – ie TODO…
    $TasksList = Get-PlannerTaskList -BucketId $BucketId
    $Taskid = ($TasksList | ? {$_.title -like $TaskName}).id
    if (!$Taskid) {
    if ($dueDate) {
    $response = New-PlannerTask -BucketID $BucketId -PlanID $PlanId -TaskName $TaskName -startDate $StartDate -dueDate $dueDate
    else {
    $response = New-PlannerTask -BucketID $BucketId -PlanID $PlanId -TaskName $TaskName -startDate $StartDate
    $TaskId = $response.id
    if ($TaskDescription) {
    Add-PlannerTaskDescription -TaskID $TaskId -Description $TaskDescription
    if ($UserPrincipalNames) {
    # Validate users – so we don’t get an unexplained fail
    foreach ($item in $UserPrincipalNames) {
    if (!(Get-AADUserDetails -UserPrincipalName $item)) {
    Write-Warning (“Could not validate user: “+ $item)
    else { $ValidatesUserNames+=$item }
    Invoke-AssignPlannerTask -TaskID $TaskId -UserPrincipalNames $ValidatesUserNames # note: bug in implementation – reports all users added multiple times
    return $TaskId
    function Set-PlannerBucket {
    param (
    [String] $PlanId,
    [String] $BucketName
    $BucketsList = Invoke-ListPlannerPlanBuckets -PlanID $PlanId
    # $buckets = Get-PlannerBucketList -PlanId $PlanId
    $bucketid = ($BucketsList | Where-Object {$_.name -like $BucketName}).id
    if (!$bucketid) {
    $response = New-PlannerBucket -PlanId $PlanId -BucketName $BucketName
    $bucketid = $response.id
    return $bucketid
    function Set-PlannerPlan {
    param (
    [String] $GroupId,
    [String] $PlanName
    $plansList = Get-PlannerPlanList -GroupId $GroupID
    $planid = ($plansList | ? {$_.title -like $planname}).id
    if (!($planid)) {
    $response = New-PlannerPlanToGroup -PlanName $PlanName -GroupID $GroupID
    $planid = $response.id
    return $planid

    • Zeng Yinghua (Sandy)

      August 3, 2019 at 03:15

      Hi Mark, you are right, now I also see it that few place could have use GET, not Inovke. Thanks for finding the typo. Since the module is out already for sometime (those older versions), I really don’t want to change the naming now, it might break other peoples scripts (if anyone is using it), thinking maybe can add the new naming and write help info in those old functions. I really like your Invoke-PlannerRestMethod function, that is very handy.

Leave a Reply

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