I've generally found the Microsoft Graph CLI (mgc) hard to work with.
In many cases, harder than using the Graph API endpoints directly or language-specific SDKs. In general, Entra directory-related
commands seem to work well, but other parts of the Graph API are rough around the edges from a usability perspective.
This doc provides some quick examples so I never have to work through the trial-and-error of figuring them out again.
Listing and downloading items
# store the drive id of the current user's onedrive
drive_id=$(mgc users drives list --user-id me | jq -r '.value.[] | select(.name == "OneDrive") | .id')
# or a simpler option might be
drive_id=$(mgc users drive get --user-id me)
# list drive items in the top-level folder (root)
mgc drives items children list --drive-id $drive_id --drive-item-id root
# or for a cleaned-up list, try this jq
mgc drives items children list --drive-id $drive_id --drive-item-id root | jq '[.value.[] | {"id": .id, "name": .name, "type": (if .folder then "folder" elif .file then "file" else null end)}]'
# download a file
mgc drives items content get --drive-id $drive_id --drive-item-id <id> --output-file <filename>A set of issues I've ran into or would be interested in seeing implemented: