Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

Planner export not working

Open fuentej opened this issue 5 years ago • 1 comments

I setup an app registration, and attempted to export planner data. But I get no results.

I tried in the GUI and in PowerShell directly. It spits out 2 files that have no useful data in them.

I have successfully exported other workloads, like teams, using the global admin account.

Perhaps I need to grant the app reg more permissions? If so what? It has basic read in graph.

fuentej avatar Jul 30 '21 18:07 fuentej

Planner is a bit different than the other workloads because it doesn't off any app only permissions. Being very transparent here, we only support Planner because these resources were developed as part of a separate project and we figured some folks may find it useful in here. However, it doesn't fall in the configuration realm and may not be a great candidate for a true DSC integration.

In order for the export to work, you will need to generate your access token manually first by running the following script and assigning the access token to a Global variable. We understand that this experience is far from optimal, but until we are able to get an App Only permissions in Planner, there are no other solutions unfortunately:

$clientId = "your App ID" $resourceURI = "https://graph.microsoft.com" $tenantName = "your tenant.onmicrosoft.com" $authUrl = "https://login.microsoftonline.com/$tenantName";

$postParams = @{ resource = "$resourceURI"; client_id = "$clientId" } $response = Invoke-RestMethod -Method POST -Uri "$authurl/oauth2/devicecode" -Body $postParams Write-Host $response.message

$tokenParams = @{ grant_type = "device_code"; resource = "$resourceURI"; client_id = "$clientId"; code = "$($response.device_code)" } $tokenResponse = $null while ([string]::IsNullOrEmpty($tokenResponse.access_token)) { try { $tokenResponse = Invoke-RestMethod -Method POST -Uri "$authurl/oauth2/token" -Body $tokenParams $accessToken = $tokenResponse.access_token $expiresOn = $tokenResponse.expires_on $refreshToken = $tokenResponse.refresh_token } catch { $errorMessage = $_.ErrorDetails.Message | ConvertFrom-Json if ($errorMessage.error -ne "authorization_pending") { throw } } }

$Global:MSCloudLoginGraphAccessToken = $accessToken

NikCharlebois avatar Aug 24 '21 12:08 NikCharlebois