
Hi @Matt Glomski
You have multiple ways to get a user's drive id.
Using Microsoft Graph PowerShell:
Import-Module Microsoft.Graph.Files
Connect-MgGraph -Scopes "Files.ReadWrite.All"
$userId = 'xxxxxxxxxxxxxxxxxx'
Get-MgUserDefaultDrive -UserId $userId
Using Azure AD PowerShell:
$clientID = 'xxxxxxxxxxx'
$secretKey = 'xxxxxxxxxxxx'
$tenantID = 'xxxxxxxxxxxxx'
$authUrl = "https://login.microsoftonline.com/" + $tenantID + "/oauth2/v2.0/token/"
$body = @{
"scope" = "https://graph.microsoft.com/.default";
"grant_type" = "client_credentials";
"client_id" = $ClientID
"client_secret" = $secretKey
}
$authToken = Invoke-RestMethod -Uri $authUrl –Method POST -Body $body
$url = "https://graph.microsoft.com/v1.0/users/xxxxxxxx/drive"
$headers = @{
"Authorization" = "Bearer $($authToken.access_token)"
"Content-type" = "application/json"
}
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get
Write-Host $response.id
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.