Which permissions are required for Graph OneDrive pre-provision to work?

Kevin Giertz 0 Reputation points
2024-09-27T09:35:14.8566667+00:00

I want to pre-provision users OneDrive using the following method:

https://video2.skills-academy.com/en-us/graph/api/drive-get?view=graph-rest-1.0&tabs=powershell

This does not however work, and the reason why is unclear.

I got two test users which both has a M365 E3 license assigned.

I'm using the permissions described in the documentation. Running 'Get-MgUserDefaultDrive' for both users gives two different errors.

$Scopes = @(
	'Files.Read'
	'Sites.ReadWrite.All'
	'Sites.Read.All'
	'Files.Read.All'
	'Files.ReadWrite.All'
)

Import-Module Microsoft.Graph.Files -RequiredVersion 2.23.0
Connect-Graph -Scopes $Scopes
Get-MgUserDefaultDrive -UserId "user1@<domain>"


Get-MgUserDefaultDrive -UserId "user2@<domain>"

The documentation states:

If the drive doesn't exist and can't be provisioned automatically (when using delegated authentication) an HTTP 404 response will be returned.

I've also tried adding a bunch of other permissions but the results are the same. No idea either why i'm getting two different error messages. So the question is why? What am i missing?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,943 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,099 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.