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://learn.microsoft.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.
12,041 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,915 questions
{count} votes

2 answers

Sort by: Most helpful
  1. CarlZhao-MSFT 42,031 Reputation points
    2024-09-30T07:01:12.5466667+00:00

    Hi @Kevin Giertz

    This should be an issue with the Graph API, it does not provision a drive for the user when you call the GET /users/{idOrUserPrincipalName}/drive endpoint.

    You need to log the user into OneDrive in the browser, after which it will provision the drive for the user.

    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.


  2. Kevin Giertz 0 Reputation points
    2024-09-30T08:23:08.87+00:00

    I've posted an issue on github regarding this. https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/2975

    0 comments No comments

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.