MSGraph Planner - How to remove assignments?

Tom Weatherill 0 Reputation points
2024-04-08T11:32:38.7566667+00:00

Hi everyone,

I'm having issues removing assignments from Planner tasks and I'm sure it's something obvious I'm doing wrong. I don't get any errors when I run the below, but it doesn't remove the assignments as per this article - plannerAssignments resource type - Microsoft Graph v1.0 | Microsoft Learn. It does remove the appliedcategories though, which makes me think it's something related to the assignments syntax.

If anyone can shine a light onto this, that would be amazing. Thanks.

Import-Module Microsoft.Graph.Planner

$ClientSecretCredential = Get-Credential -Credential "[CLIENTID]"
Connect-MgGraph -TenantId "[TENANTID" -ClientSecretCredential $ClientSecretCredential

$plannerTaskId = "[PLANNER TASKID]"

$Task = Get-MgPlannerTask -PlannerTaskId $plannerTaskId

$params = @{
	assignments = @{
		'[USERID 1]' = $null
        '[USERID 2]' = $null
		}
	appliedCategories = @{
		category3 = $false
		category1 = $false
		}
}

Update-MgPlannerTask -PlannerTaskId $plannerTaskId -BodyParameter $params -IfMatch $Task.AdditionalProperties.'@odata.etag'
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,670 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yakun Huang 80 Reputation points
    2024-04-09T07:12:21.12+00:00

    Hi @Tom Weatherill ,

    If you need removing assignments from Planner tasks, you need to send a delete request, look at your code, and see that you are sending an update request, which is used to update assignments.

    I also did the test to remove assignments and it ran successfully, share my code below.

    Import-Module Microsoft.Graph.Planner
    
    Remove-MgPlannerTask -PlannerTaskId $plannerTaskId -IfMatch 
    

    If you want to know more detailed information, you can check out this link :

    https://learn.microsoft.com/en-us/graph/api/plannertask-delete?view=graph-rest-1.0&tabs=http

    Hope this helps.

    If the reply is helpful, please click Accept Answer and kindly upvote it. If you have additional questions about this answer, please click Comment.