Created
April 7, 2021 21:57
-
-
Save garrytrinder/17f58a45693dae1a44fde2bacb86461a to your computer and use it in GitHub Desktop.
Delete completed Microsoft To Do tasks in all task lists
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Output "Getting Microsoft To Do task lists ..." | |
$lists = m365 todo list list -o json | ConvertFrom-Json | |
Write-Output "Iterating Microsoft To Do task lists ..." | |
$lists | ForEach-Object { | |
$listId = $_.Id | |
Write-Output "Getting completed tasks from '$($_.displayName)' task list ..." | |
$tasks = m365 todo task list --listId $listId -o json --query '[?status==`completed`]' | ConvertFrom-Json | |
Write-Output "$($tasks.Count) completed tasks found ..." | |
$tasks | ForEach-Object { | |
Write-Output "Removing '$($_.Title)' task ..." | |
m365 todo task remove --listId $listId --id $_.Id --confirm | |
} | |
} | |
Write-Output "Done" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# -*- coding: utf-8 -*- | |
echo "Getting Microsoft To Do task lists ..." | |
strListIds=`m365 todo list list --query '[].id'` | |
arrListIds=($strListIds) | |
echo "Iterating Microsoft To Do task lists ..." | |
for strlistId in "${arrListIds[@]}"; do | |
echo "Getting completed tasks from '${strlistId}' task list ..." | |
strTaskIds=$(m365 todo task list --listId "${strlistId}" --query '[?status==`completed`].id') | |
arrTaskIds=($strTaskIds) | |
strCount=${#arrTaskIds[@]} | |
echo "${strCount} completed tasks found ..." | |
for strTaskId in "${arrTaskIds[@]}"; do | |
echo "Removing '${strTaskId}' task ..." | |
m365 todo task remove --listId "${strlistId}" --id "$strTaskId" --confirm | |
done | |
done | |
echo "Done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment