( Updated 1 March 2023)
As part of an update to a provisioning tool I was looking into creating a Planner, a Bucket and a handful of tasks and finally connecting the Planner to a tab in one of the channels in my Teams Team.
The tool of choice is an Azure Function running PnP.PowerShell ( version 1.12 ) as this combo allows both us and the client to alter existing functions and create new ones without having to hire a hardcore developer. Quite a few consultants and IT administrators knows enough PowerShell to work with these fairly simple scripts. 💪
Creating the Planner, the bucket and the tasks goes like this: (draft version , not ready for product yet)
$localConn = Connect-PnPOnline -Url $siteUrl -ClientId $ClientId -thumbprint $thumbprint -Tenant $TenantName -ReturnConnection -erroraction stop
$PlannerPlan = Get-PnPPlannerPlan -Group $groupId -Identity $PlannerName -Connection $localConn
if(-not $PlannerPlan) { $PlannerPlan = New-PnPPlannerPlan -Group $groupId -Title $PlannerName -Connection $localConn } $bucket = Add-PnPPlannerBucket -Group $groupId -Plan $PlannerPlan.Id -Name "Tasks" -Connection $localConn
$newTask = Add-PnPPlannerTask -Group $groupId -Plan $PlannerPlan.Id -Bucket $bucket.Id -Title "Task A" -Connection $conn
$newTask = Add-PnPPlannerTask -Group $groupId -Plan $PlannerPlan.Id -Bucket $bucket.Id -Title "Task B" -Connection $conn
$newTask = Add-PnPPlannerTask -Group $groupId -Plan $PlannerPlan.Id -Bucket $bucket.Id -Title "Task C" -Connection $conn
$newTask = Add-PnPPlannerTask -Group $groupId -Plan $PlannerPlan.Id -Bucket $bucket.Id -Title "Task D" -Connection $conn
$plannerChannel = Get-PnPTeamsChannel -Team $groupId -Connection $conn | Where-Object {$_.DisplayName -eq "RFP"}
However, connecting the Planner to the tab in Teams proved to be a challange as the Add-PnPTeamsTab looks like this:
Prefect, as one of the options in the Type enum is "Planner" this should do the trick:
Add-PnPTeamsTab -Team $groupId -Channel $teamsChannel -DisplayName "RFP" -Type Planner -ContentUrl $contentUrl
But no. Error : Add-PnPTeamsTab: A parameter cannot be found that matches parameter name 'ContentUrl'.
Later in the day I saw that @PaoloPia (Paolo Pialorsi) had released a YouTube video : "Learn how to use Graph to automate provisioning of Planner plans, buckets, and tasks". In that video Paolo was using MS Graph to create the tab and connect it to the Planner.
When I added a comment on Twitter that I most likely was going to use the same approach as the Add-PnPTeamsTab approach apparently didn't work.
Gautam Sheth (@gautamdsheth) saw this and answered that I should use -type "Custom" instead as this would allow me to set the ContentUrl. This will create a Planner tab to your channel:
$teamsTab = Add-PnPTeamsTab -Team $groupId -Channel $plannerChannel -DisplayName "RFP" -Type Custom -TeamsAppId "com.microsoft.teamspace.tab.planner" -Connection $conn -ContentUrl "https://tasks.office.com/[TenantName].onmicrosoft.com/Home/PlannerFrame?page=7&planId=$($PlannerPlan.Id)" So thanks to a comment on Twitter and to Paolo and Gautam I learned something new, got the function to work using PnP.PowerShell exclusively. In order to ensure that this option reaches a broader audience the documentation for Add-PnPTeamsTab has been updated with a example like the code above.
Update 1 March 2023:
Gautam has updated the Cmdlet and I have updated the documentation with this example:
No need to use -Type Custom anymore ✌
Comments